将列表拆分为python中的单个字符

时间:2016-04-20 16:42:26

标签: python list

我有这个列表['MEYFDAHCHLNCEPLLSEIEKSIANFKLINLKANVVGTDLDNSKIAVELAKKYPDLLKATIGIHPNDVHLVDFKKTKKQLNELLINNRNFISCIGEYGFDYHYTTEFIELQNKFFEMQFEIAETNKLVHMLHIRDAHEKIYEILTRLKPTQPVIFHCFSQDINIAKKLLSLKDLNIDIFFSIPGIVTFKNAQALHEALKIIPSELLLSETDSPWLTPSPFRGKVNWPEYVVHTVSTVAEIKKIEIAEMKRIIVKNAKKLFWH']

我已将其保存到名为proteinseq的列表中,并希望将其单独拆分,以便只能打印前20个字符。我怎么能在python中这样做?

1 个答案:

答案 0 :(得分:4)

看起来您的列表中只有1个项目。

proteinseq[0][:20] # Get up to the 20 characters from the 1st item in the list