python 怎么导航文件夹名称
方法一:f = open('foo.txt') # 返回一个文件对象line = f.readline() # 调用文件的 readline()方法while line:print line, # 后面跟 ',' 将忽略换行符print(line, end = '') # 在 Python 3中使用line = f.readline()f.close()方法二:for line in open('foo.txt'):print line,方法三:f = open('c:\1.txt','r')lines = f.readlines()#读取全部内容for line in linesprint line
赞0
踩0