python常用函数
max()
height = {'swz':180, 'dj':170, 'zs':160, 'fll':150}
max(height, key=lambda x:height[x])
map():映射
namel=['dj','fll','zs']
map(func,namel)
map(lambda x:x+'sb',namel)
py2正常返回
py3返回迭代器
reduce():合并(相加)可以处理字符串
py3需要导入
from functools import reduce
reduce(lambda x, y:x+y, [i for i in range(101)],200)
最后参数为初始值
filter():过滤
namel=['djsb','fllsb','zssb','swz']
filter(lambda x:x.endswith('sb'),namel)