1 a = [x for x in range(10)] 2 print (a) 3 ''' 4 [0,1,2,3,4,5,6,7,8,9] 5 ''' 6 a = [x*2 for x in range(10) ] 7 ''' 8 [0,2,4,6,8,10,12,14,16,18] 9 '''
也可以放置函数f(x) 对生成的列表中的每个元素进行操作