更新时间:2023-02-05 14:20:15
你需要这样的东西:
composite_list = [my_list[x:x+5] for x in range(0, len(my_list),5)]
print (composite_list)
输出:
[['-200', ' 0', ' 200', ' 400', ' green'], ['0', '0', '200', '400', ' yellow'], ['200', '0', '200', '400', ' red']]
新5个元素是什么意思?
What do you mean by a "new" 5 elements?
如果你想要附加到此列表即可:
If you want to append to this list you can do:
composite_list.append(['200', '200', '200', '400', 'bluellow'])