我看过多个问题帖子,我想知道如何摆脱文件的最后一行,或者说是空白行
infile = open("milkin.txt","r").readlines()
outfile = open("milkout.txt","w")
number = infile[0]
arrayLoc = infile[1].split( )
array = infile[2].split( )
dictionary = {}
for i, z in zip(arrayLoc, array):
dictionary[i] = z
for key in sorted(dictionary):
outfile.write(dictionary[key])
outfile.write("\n")
outfile:
5520059
8089172
7180540
6513926
9202362
2641421
2897763
2383426
1490027
1368690
在数字下方有一条多余的线,我想将其删除
ibeautiful
慕慕森
相关分类