更新时间:2023-12-05 16:44:52
如果所有列表都存储在列表 a
中,
If you have all of your lists stored in a list a
,
# a = [[.45], [.87], ...]
import itertools
output = list(itertools.chain(*a))
此答案之所以比其他答案更好,是因为它整齐地将任意数量的列表连接在一起,而不需要 for
循环之类的东西.
What makes this answer better than the others is that it neatly joins an arbitrary number of lists together in one line, without a need for a for
loop or anything like that.