Python逐行读取文件内容


Python逐行读取文件内容
thefile= open("foo.txt")
line = thefile.readline()
while line: print line,
  line = thefile.readline() thefile.close()


Windows下文件路径的写法:
E:/codes/tions.txt


写文件:
thefile= open("foo.txt", "rw+")
for item in thelist: thefile.write("%s\n"% item)
thefile.close()
 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM