list赋值操作
在列表list外乘以某个数
[x]*3
该操作表明对列表的数据进行复制
example1
x = [1, 2]
y = [[1],[2]]
x_mul = x*3
x_mul_one = [x]*3
y_mul = y*3
print x_mul
print x_mul_one
print y_mul
x_mul ==> [1, 2, 1, 2]
x_mul_one ==> [[1, 2], [1, 2]]
y_mul ==> [[1], [2], [1], [2]]
list中包含循环操作
将循环操作嵌入list列表中
list_one = [1, 2, 3, 4]
operation_list = [a[element] for element in list_one]
print operation_list
结果:[1, 2, 3, 4]
list_one = [[1,1], [2,2], [3,3], [4,4]]
operation_list = [[a, b] for [a, b]] in list_one]
print operation_list
结果:[[1,1], [2,2], [3,3], [4,4]]