python内置函数

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

                                                                       内置函数
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()

简单演示几个python

all(iterable)函数

全部元素都为真,返回True,不然返回False (非0,即为真。空为False)spa

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

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

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

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

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

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

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

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

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

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

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

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

相关文章
相关标签/搜索