%下面是lambda的示例,它包含三个参数并添加前两个参数。
1
my_function = lambda a, b, c : a + b 2 my_function(1, 2, 3)
3

1 my_list = []
2 for number in range(0, 1000):
3     if number % 2 == 0:
4         my_list.append(number)
5 my_list
[0,
 2,
 4,
 6,
 8,
 10,
 12,
 14,
 16,
 18,
...
...
998]

%与上面相同效果
1
my_list = [number for number in range(0,1000) if number % 2 == 0] 2 my_list
[0,
 2,
 4,
 6,
 8,
 10,
 12,
 14,
 16,
 18,
...
...
998]







posted on 2018-03-05 20:03  郑哲  阅读(111)  评论(0编辑  收藏  举报