我就是想把一个文件中的一些内容写进另一个txt里,然后运行后txt就变成了一堆乱码
with open('file.gff', 'r+') as f1, open('number.count'
, 'r+') as f2, \
open('新文件.txt', 'w+') as new_file, \
open('file1.txt', 'r+')as f4:
for i in f2:
i = i.strip().split("\t")
print(i)
list(i)
new_file.truncate(0)
id6 = i[0]
qqq = i[6]
print(id6)
if int(qqq) != 0:
new_file.write(str(id6) + '\n')
print(qqq)
for w in new_file:
w1 = w.strip().split('\t')
print(w)
for q in f1:
we = []
qq = q.strip().split('\t')
if str(qq[2]) == 'gene':
print(qq[-1])
we.append(qq[-1])
print(we)
q1 = qq[-1][3:21]
print(q1)
if id6 == q1:
f4.write('gene_id chr loc1 loc2\n' + i[0:-30] + ' ' + q[-31:-34] + ' ' + q[22:29] + ' ' + q[29:36])
运行之后就是一大堆这个东西:NULNUL
我重复运行了好几次,但就是一堆乱码