1.readline读取整个文件
input = open('File','r')
while True:
line = input.readline()
if not line:
break
input.close()
2.python2 next()
input = open('File','r')
for line in input:
line = line1.strip("\n")
input.close()
3.python3 next()
input = open('File','r')
for line in input:
line = line1.strip("\n")
input.close()
参考文章:
Python逐行读取文件,到最后一行结束
网友评论