>>> a = [[1, 2, 3], [4, 5, 6]]
>>> b = [x for x in i for i in a]
>>> b
[1, 1, 2, 2, 3, 3]
>>> c = [x for x in i for i in a]
>>> c
[4, 4, 5, 5, 6, 6]
如何解释上面代码的运行结果?
一般的得到的结果是[4, 4, 5, 5, 6, 6],但是偶然会得到[1, 1, 2, 2, 3, 3],这是为什么呢?
如何把[[1, 2, 3], [4, 5, 6]]用列表推导成[1,2,3,4,5,6]的形式?
慕标5832272
凤凰求蛊
侃侃无极
相关分类