最后一个新行消失(gedit)

问题描述 投票:-1回答:1

如果我在gedit中打开它,最后一行会在文件in0output0中消失,我不知道为什么?

在linux2上的Python 2.7.15rc1(默认,2018年11月12日,14:31:15)[GCC 7.3.0]

from math import ceil, floor, log
from random import randint, choice

def in2text(table):
        out=''
        out+=str(len(table))+'\n'
        for t in table:
                out+=(str(t[0])+' '+str(t[1])+'\n')
        return out

def out2text(table):
        out=''
        for t in table:
                out+=(str(t)+'\n')
        return out

nr_inst=1000
max_n=1000000
in0=[randint(1, max_n) for e in range(1,nr_inst+1)]
input0=[[i,i] for i in in0]
output0=[5 for n,x in input0]

fin=open("in0","w")
fout=open("out0","w")
fin.write(in2text(input0))
fout.write(out2text(output0))
fin.close()
fout.close()

写功能?如果我打印in2text(input0),那么我可以看到最后一个新行(输入'\ n')。

我得到(在out0):

5
5
5
...
5
5

没有最后一个新行(空的新行)。我想要:

5
5
5
...
5
5
<new line>

为什么gedit不显示这一行?错误?

python gedit
1个回答
0
投票

代码本身运行正常,而不是您之后查看文件的方式。具体来说,这似乎是gedit中存在的错误。

bugs.launchpad.net/ubuntu/+source/gedit/+bug/1621732

确认2018-11-06

© www.soinside.com 2019 - 2024. All rights reserved.