- 自带的tkinter模块
from tkinter import _flatten
arr = [[1, 2, 3], [7, 8, 9]]
t = list(_flatten(arr))
print(t)
>>> [1, 2, 3, 7, 8, 9]
- 自带的itertools模块
arr = [[1, 2, 3], [7, 8, 9]]
t = list(chain.from_iterable(arr))
print(t)
>>> [1, 2, 3, 7, 8, 9]
- 用sum对列表的求和
arr = [[1, 2, 3], [7, 8, 9]]
t = sum(arr, [])
print(t)
>>> [1, 2, 3, 7, 8, 9]