内置函数和匿名函数

1,68个内置函数

abs() dict() help() min() setattr()
all() dir() hex() next() slice()
any() divmod() id() object() sorted()
ascii() enumerate() input() oct() staticmethod()
bin() eval() int() open() str()
bool() exec() isinstance() ord() sum()
bytearray() filter() issubclass() pow() super()
bytes() float() iter() print() tuple()
callable() format() len() property() type()
chr() frozenset() list() range() vars()
classmethod() getattr() locals() repr() zip()
compile() globals() map() reversed() __import__()
complex() hasattr() max() round()  
delattr() hash() memoryview() set()

请务必重点掌握:

其他:input,print,type,hash,open,import,dir

str类型代码执行:eval,exec

数字:bool,int,float,abs,divmod,min,max,sum,round,pow

序列——列表和元组相关的:list和tuple

序列——字符串相关的:str,bytes,repr

序列:reversed,slice

数据集合——字典和集合:dict,set,frozenset

数据集合:len,sorted,enumerate,zip,filter,map

2,匿名函数

#这段代码
def calc(n):
  return n**n
print(calc(10))

#换成匿名函数
calc = lambda n:n**n
print(calc(10))

上面是我们对calc这个匿名函数的分析,下面给出了一个关于匿名函数格式的说明

函数名 = lambda 参数 :返回值

#参数可以有多个,用逗号隔开
#匿名函数不管逻辑多复杂,只能写一行,且逻辑执行结束后的内容就是返回值
#返回值和正常的函数一样可以是任意数据类型
原文地址:https://www.cnblogs.com/l-jie-n/p/9582411.html