我在一个看起来像这样的列表中有一组序列:
[agghd,gjg,tomt]
如何分割它,这样我的输出如下所示:
[[a,g,g,h,d],[g,j,g],[t,o,m,t]]
我现在已经完成以下代码:
agghd
gjh
tomt
list2=[]
list2 = [str(sequences.seq).split() for sequences in family]
您可以通过在其上调用list()
将字符串拆分为字符
list1 = ['agghd', 'gjg', 'tomt']
list2 = [list(string) for string in list1]
# output: [['a', 'g', 'g', 'h', 'd'], ['g', 'j', 'g'], ['t', 'o', 'm', 't']]
您可以尝试
[[eval(n) for n in str(sequences.seq).split()] for sequences in family]