如何将[]作为元素添加到Python中的列表列表中?

时间:2014-11-25 18:34:11

标签: python list

a = [["GE", "US", "UK", ....], [12, 11, 29, ...]]

现在我想添加其他5个变量,并得到如下结果:

a = [["GE", "US", "UK", ....], [12, 11, 29, ...], ["a", "b", "c", ...], [...], [...], ...]

2 个答案:

答案 0 :(得分:2)

您可以附加要添加的每个列表:

a.append(["a", "b", "c"])

答案 1 :(得分:1)

您可以使用+运算符来连接列表

>>> a = [["GE", "US", "UK"], [12, 11, 29]]
>>> a += [['a','b','c'], [],[],[]]
>>> a
[['GE', 'US', 'UK'], [12, 11, 29], ['a', 'b', 'c'], [], [], []]