1.sort
>>> list1 = [3,5,-4,-1,0,-2,-6]
>>> sorted(list1, key=lambda x: abs(x))
[0, -1, -2, 3, -4, 5, -6]
2.闭包
>>> def my_add(n):
return lambda x:x+n
>>> add_3 = my_add(3)
>>> add_3(7)
10
1.sort
>>> list1 = [3,5,-4,-1,0,-2,-6]
>>> sorted(list1, key=lambda x: abs(x))
[0, -1, -2, 3, -4, 5, -6]
2.闭包
>>> def my_add(n):
return lambda x:x+n
>>> add_3 = my_add(3)
>>> add_3(7)
10