可能重复:Making a flat list out of list of lists in PythonJoin a list of lists together into one list in Python
我有很多列表,看起来像
['it']
['was']
['annoying']
我希望上面看起来像
['it', 'was', 'annoying']
我该如何实现?
只需添加它们:
import itertools
ab = itertools.chain(['it'], ['was'], ['annoying'])
list(ab)
a = ['it']
b = ['was']
c = ['annoying']
a.extend(b)
a.extend(c)
# a now equals ['it', 'was', 'annoying']