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'

原本準備好好寫一遍博客。。。。

發現好多內置函數我沒法用簡單的方式,給你們描述清楚,若是寫出來可能要耗費太多的時間,精力(後面可能會有更好的文章給你們),更多方法點擊頂部網址自行查看(請各位原諒個人懶惰)。

相關文章
相關標籤/搜索