赞
踩
1.txt
with open(‘1.txt’) as fp: result=[0,’’] #初始值 for line in fp: #一个一个遍历 t=len(line) if t>result[0]: result=[t,line] #t更大就重新赋值 print(result)
结果如图