python - 将多个列表合并到 1 个列表中

标签 python list

这是我拥有的:

list1 = ['a', 'b', 'c']
list2 = ['d', 'e', 'f']
list3 = ['g', 'h', 'i']

这就是我想要的:

list4 = [['a', 'b', 'c'],['d', 'e', 'f'],['g', 'h', 'i']]

如何解决这个问题?

最佳答案

要创建这样的列表列表,只需使用:

list4 = [list1, list2, list3]

关于python - 将多个列表合并到 1 个列表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62932907/

相关文章:

c++ - C++ 中 pop_front() 的段错误

list - 从 clojure 中的函数返回列表

python - 在发送请求之前重写 scrapy URL

python ,datetime.date : difference between two days

python - 将理解列表打印为字符串

c# - 在 C# 列表中查找最少出现的成员

python - 在需要列表或元组的情况下传递参数时要传递什么?

python - Sqlalchemy 选择条件

Python,压扁一个丑陋的嵌套for循环

python - Base64 到二进制转换的问题