for 实现:
import os;
# python 逐行读取文本
for line in open( "c:\\testLineCount.txt", encoding = "utf-8" ): #
print( line );
#
while 实现:
path = "C:\\testLineCount.txt"
file1 = open( path, "r", encoding = "utf-8" )
while True: #
mystr = file1.readline() #表示一次读取一行
# 读到数据最后跳出,结束循环。数据的最后也就是读不到数据了,mystr 为空的时候
if mystr == '': # 或 if not mystr:
break;
print( mystr )
#
file1.close();