在python中合并多个list到一个list的方法

参考自网页:https://www.stechies.com/concatenate-merge-two-or-multiple-lists-in-python/

我认为最好的一个方法是:

list1 = [2,3,4,2,2]
list2 = [4,5,6,7,34,56]
list3 = [1,5,33,2,34,46]

# Concatenate lists
newlist = [y for x in [list1, list2, list3] for y in x]

 

posted @ 2021-11-26 11:26  百变小超  阅读(1702)  评论(0编辑  收藏  举报