#读取文件
fr = open('Homo_sapiens.GRCh38.87.chr.gtf','r')
#输出到文件166out
fw = open('166out','w')
n = 0
for line in fr:
if line.startswith("#"):
m = 0
else:
line = line.strip().split('\t')
if line[0] == n or line[0] == '1':
n = line[0]
if line[2] == 'transcript':
m += 1
else:
print(n,file=fw)
print(m,file=fw)
m = 0
n = line[0]
m = 1
结果