>chr1 <_io.TextIOWrapper name='result.fa' mode='w' encoding='UTF-8'>
001、问题
[root@pc1 test4]# ls a.fa test.py [root@pc1 test4]# cat a.fa >chr1 aatt cc >chr2 ttgg ccttgg >chr3 TTCCGG cctt ccgg [root@pc1 test4]# cat test.py #!/usr/bin/python in_file = open("a.fa", "r") out_file = open("result.fa", "w") for i in in_file: i = i.strip() if i.startswith(">"): print(i, out_file) [root@pc1 test4]# python test.py >chr1 <_io.TextIOWrapper name='result.fa' mode='w' encoding='UTF-8'> >chr2 <_io.TextIOWrapper name='result.fa' mode='w' encoding='UTF-8'> >chr3 <_io.TextIOWrapper name='result.fa' mode='w' encoding='UTF-8'>

002、解决方法
[root@pc1 test4]# cat test.py #!/usr/bin/python in_file = open("a.fa", "r") out_file = open("result.fa", "w") for i in in_file: i = i.strip() if i.startswith(">"): print(i, file = out_file) ## 在此处添加 file =


浙公网安备 33010602011771号