python:关键字

Python中包含了大量的关键字和内置函数,在取变量名时,应该避免去使用关键字,否则会报错。如果使用内置函数名称,则不会报错,但是会覆盖原有内置函数的功能。

内置函数:
Python:内置函数 - 汇总

Python:内置函数1 - 数据类型转换
Python:内置函数2 - 基本操作
Python:内置函数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()

关键字:

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']
图片
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容