新聞中心
這里有您想知道的互聯網營銷解決方案
創(chuàng)新互聯Python教程:Python內置函數一覽表
為了提高程序員的開發(fā)效率,Python 提供了很多可以直接拿來用的函數(初學者可以先理解為方法),每個函數都可以幫助程序員實現某些具體的功能。

創(chuàng)新互聯是一家專注于成都做網站、成都網站設計與策劃設計,葉集網站建設哪家好?創(chuàng)新互聯做網站,專注于網站建設十余年,網設計領域的專業(yè)建站公司;建站業(yè)務涵蓋:葉集等地區(qū)。葉集做網站價格咨詢:028-86922220
舉個例子,在 Python 2.x 中 print 只是一個關鍵字,但在 Python 3.x 中,print 是用于打印輸出的函數,而且還是一個內置函數,通過此函數,我們可以直接將數據做輸出操作,比如說:
>>>print("php中文網")
php中文網除了 print() 函數之外,Python 還提供了很多內置函數,表 1 中羅列出了 Python 3.x 環(huán)境中的所有內置函數。
| 內置函數 | ||||
|---|---|---|---|---|
| abs() | delattr() | hash() | memoryview() | set() |
| all() | dict() | help() | min() | setattr() |
| any() | dir() | hex() | next() | slicea() |
| 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() | |
需要注意的是,開發(fā)者不建議使用以上內置函數的名字作為標識符使用(作為某個變量、函數、類、模板或其他對象的名稱),雖然這樣做 Python 解釋器不會報錯,但這會導致同名的內置函數被覆蓋,從而無法使用。例如:
>>> print="php中文網" #Python解釋器不會報錯 >>> print(print) Traceback (most recent call last): File "", line 1, in print(print) TypeError: 'str' object is not callable
分享標題:創(chuàng)新互聯Python教程:Python內置函數一覽表
文章源于:http://www.5511xx.com/article/dpdcpsp.html


咨詢
建站咨詢
