Python中包含了大量的關(guān)鍵字和內(nèi)置函數(shù),在取變量名時,應(yīng)該避免去使用關(guān)鍵字,否則會報錯。如果使用內(nèi)置函數(shù)名稱,則不會報錯,但是會覆蓋原有內(nèi)置函數(shù)的功能。
內(nèi)置函數(shù):
Python:內(nèi)置函數(shù) - 匯總
Python:內(nèi)置函數(shù)1 - 數(shù)據(jù)類型轉(zhuǎn)換
Python:內(nèi)置函數(shù)2 - 基本操作
Python:內(nèi)置函數(shù)3 - 進階操作
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() 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()
delattr() hash() memoryview() set()
關(guān)鍵字:
import keyword
print(keyword.kwlist)
['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']
圖片