python列表展平 s = [1, [2, [3, [4, [5, 6], 7], 8], (9, 0)]] f = lambda x: [y for _x in x for y in f(_x)] if isinstance(x, (list, tuple)) else [x] print(f(s)) # [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] numpy数组转一维 data.flatten() data.reshape()