Python的内置函数和匿名函数
一、Python常用内置函数
abs() | divmode() | input() | open() | filter() |
---|---|---|---|---|
all() | int() | max() | map() | zip() |
eval() | print() | str() | pow() | sum() |
super() | bin() | file() | tuple() | bool() |
len() | range() | type() | float() | list() |
参考网址:http://www.runoob.com/python/python-built-in-functions.html
1、abs()函数:求数字的绝对值
例:
ret=abs(-21)
print(ret)
运行结果:
2、map()函数
有两个参数,第一个参数是一个函数,第二个参数是可迭代的内容。函数会依次作用在可迭代内容的每一个元素上进行计算,然后返回一个新的可迭代内容。
例:求 lst 中每一个元素的平方值
lst