简体   繁体   English

如何制作一个列表以拆分成每个元素并创建一个子列表

[英]How to make a list to split into each element and make a sublist

If I have this list, 如果我有这个清单,

list01 = ['GAGGT','TCCGT','ABECF']

I want to make each element in the list to split, but still remain in the same box of list. 我想分割列表中的每个元素,但仍保留在列表的同一框中。 Like this: 像这样:

listalt = [['G','A','G','G','T'],['T','C','C','G','T'],['A','B','E','C','F']] 
listalt = [list(i) for i in list01]

这是一个列表理解 ,并利用list可以采用可迭代(如字符串)并将其转换为list事实

You can use this : 您可以使用:

final_list=[]
for item in list01:
    final_list.append(list(item))

print(final_list)

which is same as : 与:

print([list(item) for item in list01])

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何破坏子列表,使子列表中的每个元素成为python列表中的普通元素 - How to break sublist to make each element in the sub list a normal element in the list in python 如何制作一个新列表,该列表具有每个列表的第一个元素但分为 3 个? - How can I make a new list that has the first element of each of the list but split into 3? 如何制作将子列表添加到列表的函数 - How to make a function that adds a sublist to a list 如何使文件的每一行成为包含整个文件的列表的子列表? - How can I make each line from a file a sublist, of a list that encompasses the whole file? 如何在不创建子列表的情况下拆分python列表元素 - How do i split a python list element without creating a sublist 如何在python中将列表拆分为子列表 - How to split the list into sublist in python 如果pandas系列的值是一个列表,如何获取每个元素的子列表? - If the value of pandas series is a list, how to get a subList of each element? 如何在每个子列表的索引[0]处拆分字符串,并将每个拆分索引放在它自己的原始列表中? - How to split string at index[0] of each sublist, and have each split index in it's own original list? 如何在Python中的字符串中创建一个没有子列表的列表 - How to make one list without a sublist from a string in Python 如何使用列表理解使zip()中的每个元素成为列表? - How to make each element a list from zip() with list comprehensions?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM