python循环读取txt文件内容

#D盘中有文件test.txt
files=open("D:\\test.txt","r+")

#先读取一行
str=files.readline()

#循环读取
while str:
    print str
    str=files.readline()
files.close()

更多推荐

python循环读取txt文件