Python全栈之路----函数----内置方法

Built-in Functions
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() insubclass() 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()  
  • abs()  取绝对值
  • dict()  把一个数据转成字典
  • help()  帮助
  • min()  从列表中取出最小数
>>> a  = [1,4,5,-1,3]
>>> min(a)
-1
  • max()  从列表中取出最大数
>>> a  = [1,4,5,-1,3]
>>> max(a)
5
  • setattr()  后面面向对象用到,此处省略
  • all()  如果bool(x)为True,即x中所有元素均为True,all(x)为True。如果x是可循环的(列表为可循环的),all(x)也返回True。

空列表或列表内元素全为True,all()为True。

#一种特殊情况
>>> bool([])
False
>>> all([])
True
  • any()  
#和all相反,只要有列表中有一个元素为True,any即为True
>>> any([False,0])
False
>>> any([False,0,1])
True
>>> any([])
False
  • dir()  打印当前程序中存在的所有变量
  • hex()  
  • next()  
  • slice()  
  • divmod()  
  • id()  
  • object()  
  • sorted()  
  • ascii()  
  • enumerate()  
  • input()  
  • oct()  
  • staticmethod()  
  • bin()  
  • eval()  
  • int()  
  • open()  
  • str()  
  • bool()  判断True or False,只有0是False
  • exec()  
  • isinstance()  
  • ord()  
  • sum()  
  • bytearray()  
  • filter()  
  • insubclass()  
  • 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()  

猜你喜欢

转载自www.cnblogs.com/Moxiaoyu666/p/10366680.html
今日推荐