python初学笔记(2)
程序员文章站
2022-06-20 18:15:06
文件处理:
读文件:
f1 = file("d:\\document_classification\\sports_urlfilepair.txt",...
文件处理:
读文件:
f1 = file("d:\\document_classification\\sports_urlfilepair.txt",'r')
while true:
line = f1.readline()
if(line == "\n" or line == ""):
break
tmp = line.split("\t")
写文件:
f2 = file("d:\\document_classification\\sports.txt","w")
f2.write()
目录处理:
读取目录下的文件名称及路径:
for i in os.listdir(directory):
string = directory+"\\"+i
读文件:
f1 = file("d:\\document_classification\\sports_urlfilepair.txt",'r')
while true:
line = f1.readline()
if(line == "\n" or line == ""):
break
tmp = line.split("\t")
写文件:
f2 = file("d:\\document_classification\\sports.txt","w")
f2.write()
目录处理:
读取目录下的文件名称及路径:
for i in os.listdir(directory):
string = directory+"\\"+i
上一篇: 关于python文件操作