我在变量resultset
中存储了以下内容:
(['James Taylor'],['Sarah Jarosz'],['Crooked Still'])
我想把它重写为一个列表,即['James Taylor','Sarah Jarosz','Crooked Still']。
我该怎么做?提前致谢
答案 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]