list除了基础的创建方式外,生成具有一定规律的list
例如:
生成[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
list1 = list(range(1, 11))
2.生成具有一定规律的算式的列表
list2 = [2 * x - 1 for x in range(1, 11)]
-----> [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
3.数学全排列
list3 = [m + n for m in 'abc' for n in 'xy']
-----> [ax, ay, bx, by, cx, cy]
4,字典生产list
dic = {'a':'1', 'b':'2', 'c':'3'}
list4 = [k + '=' + v for k, v in dic.items()]
----> ['a=1', 'b=2', 'c=3']