python 代码收藏

简易计算小文本文件的行数
fobj=open(filepath,mode)
count=fobj.readlines()
print count
即可
对文件如果过大的话,需要另外写脚本
 
return max(len(x.strip()) for x in open( filepath))
 
 
f=open(filename,mode)
alllines=(len(x.strip()) for x in f)
f.closed()
列表解析实例  
 
 
 
原文地址:https://www.cnblogs.com/zthua/p/2853342.html