的名单我有这样转换列表的列表,以字符串
list1 = [['I am a student'], ['I come from China'], ['I study computer science']]
len(list1) = 3
列表的列表现在我想将其转换成字符串列表这样
list2 = ['I', 'am', 'a', 'student','I', 'come', 'from', 'China', 'I','study','computer','science']
len(list2) = 12
我我知道,我可以转换这样
new_list = [','.join(x) for x in list1]
但它返回
['I,am,a,student','I,come,from,China','I,study,computer,science']
len(new_list) = 3
我也试过这个
new_list = [''.join(x for x in list1)]
,但它提供了以下错误
TypeError: sequence item 0: expected str instance, list found
我如何在列表1的子表中提取每一个字,并把它转换成字符串列表?我使用python 3在Windows 7
列表1有一个元素是有三个元素的列表。 – bohrax
如果列表1有你的问题可能应该改写,以“转换句子的列表单词列表”三个要素 – bohrax
@bohrax,对不起,我已编辑的问题,它应该是列表的列表。 –