python内置函数

官方网址:https://docs.python.org/3/library/functions.html

                                                                       内置函数
abs() delattr() hash() memoryview() set()
all() dict() help() min() setattr()
any() dir() hex() next() slice()
ascii() divmod() id() object() sorted()
bin() enumerate() input() oct() staticmethod()
bool() eval() int() open() str()
breakpoint() 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()

简单演示几个

all(iterable)

所有元素都为真,返回True,否则返回False (非0,即为真。空为False)

In [2]: all([1,2,3])
Out[2]: True

In [3]: all([0,2,3])
Out[3]: False

any(iterable)  只要有一个元素为真,则返回True

In [5]: any([1,2,2])
Out[5]: True

In [6]: any([0,2,2])
Out[6]: True

In [7]: any([])
Out[7]: False

bin(x)  十进制转为二进制

In [8]: bin(10)
Out[8]: '0b1010'

In [9]: bin(100)
Out[9]: '0b1100100'

In [10]: bin(255)
Out[10]: '0b11111111'

本来准备好好写一遍博客。。。。

发现好多内置函数我无法用简单的方式,给大家描述清楚,如果写出来可能要耗费太多的时间,精力(后面可能会有更好的文章给大家),更多方法点击顶部网址自行查看(请各位原谅我的懒惰)。

 

posted on 2019-02-16 16:35  改变就是好事  阅读(289)  评论(0编辑  收藏  举报

导航