【发布时间】:2018-08-03 02:12:23
【问题描述】:
我查看了多个问题帖子,我想知道如何摆脱文件的最后一行,或者说,一个空白行
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
数字下面多了一行,我想删除它
【问题讨论】:
标签: python python-3.x io