将字符串列表写入文件
我有一个缩写列表
Letters = ['Ala', 'Asx', 'Cys', ... 'Glx']
我想将其输出到一个文本文件,如下所示:
#Letters
Ala、Asx、Cys、..... Glx
Noob 程序员在这里!我总是忘记最简单的事情!啊,
请帮忙,谢谢!
import Bio
from Bio import Seq
from Bio.Seq import Alphabet
output = 'alphabetSoupOutput.txt'
fh = open(output, 'w')
ThreeLetterProtein = '#Three Letter Protein'
Letters = Bio.Alphabet.ThreeLetterProtein.letters
fh.write(ThreeLetterProtein + '\n')
#Don't know what goes here
fh.close()
I have a list of abbreviations
Letters = ['Ala', 'Asx', 'Cys', ... 'Glx']
I want to output this to a text file that will look this like:
#Letters
Ala, Asx, Cys, ..... Glx
Noob programmer here! I always forget the simplest things! ah
please help and thanks!
import Bio
from Bio import Seq
from Bio.Seq import Alphabet
output = 'alphabetSoupOutput.txt'
fh = open(output, 'w')
ThreeLetterProtein = '#Three Letter Protein'
Letters = Bio.Alphabet.ThreeLetterProtein.letters
fh.write(ThreeLetterProtein + '\n')
#Don't know what goes here
fh.close()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
fh.write(', '.join(Letters))
怎么样?How about
fh.write(', '.join(Letters))
?我对生物包了解不多,但我猜......
或者
I don't know much about the bio package but I guess ...
or