Python将列表的元组转换为列表

时间:2017-04-14 03:29:17

标签: python list tuples

我在变量resultset中存储了以下内容:
(['James Taylor'],['Sarah Jarosz'],['Crooked Still'])

我想把它重写为一个列表,即['James Taylor','Sarah Jarosz','Crooked Still']。

我该怎么做?提前致谢

2 个答案:

答案 0 :(得分:1)

如果这实际上不是重复:

resultset = (['James Taylor'], ['Sarah Jarosz'], ['Crooked Still'])
new_list = [i[0] for i in resultset]
print new_list

['James Taylor','Sarah Jarosz','弯曲仍然']

答案 1 :(得分:1)

您也可以使用:

l = (['James Taylor'], ['Sarah Jarosz'], ['Crooked Still']) 
new_l = [item for sublist in l for item in sublist]