python
[[0.5587, 0.549, 0.5424], [0.53, 0.4896, 0.5178, 0.5127, 0.5168, 0.4794, 0.5011, 0.5099, 0.5421, 0.5928, 0.5147, 0.5194, 0.5127, 0.4892, 0.5468, 0.5204, 0.521, 0.5259], [0.5381, 0.5095, 0.516, 0.5262, 0.5688, 0.527, 0.5262]]
就比如这个, 找出这段[0.53, 0.4896, 0.5178, 0.5127, 0.5168, 0.4794, 0.5011, 0.5099, 0.5421, 0.5928, 0.5147, 0.5194, 0.5127, 0.4892, 0.5468, 0.5204, 0.521, 0.5259]
const findMaxLengthItem = arr => arr.map((item, i) => ({ length: item.length, item })).reduce((p, c) => {
if (p.length < c.length) {
return c
} else {
return p
}
}, { length: 0 }).item
mp = map(len, lst)
lst[list(map(len, lst)).index(max(mp))]
没想好。这样也可以。主要是获取float的长度
test = [
0.53, 0.4896, 0.5178,
0.5127, 0.5168, 0.4794,
0.5011, 0.5099, 0.5421,
0.5928, 0.5147, 0.5194,
0.5127, 0.4892, 0.5468,
0.5204, 0.521, 0.5259
]
max = max([str(i).find('.')+str(i)[::-1].find('.') for i in test])
print([i for i in test if str(i).find('.')+str(i)[::-1].find('.') == max])
li=[[0.5587, 0.549, 0.5424], [0.53, 0.4896, 0.5178, 0.5127, 0.5168, 0.4794, 0.5011, 0.5099, 0.5421, 0.5928, 0.5147, 0.5194, 0.5127, 0.4892, 0.5468, 0.5204, 0.521, 0.5259], [0.5381, 0.5095, 0.516, 0.5262, 0.5688, 0.527, 0.5262]]
longest=0
longestli=[]
for l in li:
if len(l)>=longest:
longest=len(l)
longestli=l
print(f"最长的:{l}")