Python文件的读取与写入
老朽八百岁 2019-04-19 08:34:16 h=open('pinyin_score.txt','w')
count = len(open('name_pinyin.txt','r').readlines())
name1_list=[]
name2_list=[]
count = len(open('name_pinyin.txt','r').readlines())
with open('name_pinyin.txt','r') as f1 ,
open('name_score.txt','r') as f2:
name1=f1.readlines()
name2=f2.readlines()
for i in (0,count-1):
for j in (0,count-1):
if (name1[i].split(',',1)==name2[j].split(' ',1)):
print("%s %s" %(name1[i].split(',' , '\n', 2),name2[j].split(' ','\n',2)),file=h,end='')
else:
pass
f1.close()
f2.close()
h.close()
为什么写入的文件夹是空的?