首页 > 编程语言 > 详细

Python逐行读取文件内容

时间:2015-04-18 20:29:32      阅读:152      评论:0      收藏:0      [点我收藏+]
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()
 

Python逐行读取文件内容

原文:http://www.cnblogs.com/emanlee/p/3451499.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!