每种编程语言都会有一些特殊的单词,称为关键词。对待关键词的基本要求是,你在命名的时候要避免与之重复。本文将介绍一下Python中的关键词。关键词不是内置函数或者内置对象类型,虽然在命名的时候同样也最好不要与这些重名,但是,毕竟你还可以使用与内置函数或者内置对象类型重名的名称来命名。关键词则不同,它是不允许你使用。
False await else import passNone break except in raise
True class finally is return
and continue for lambda try
as def from nonlocal while
assert del global not with
async elif if or yield
如果打算在交互模式里面查看关键词,可以使用help():
>>> help("keywords") Here is a list of the Python keywords. Enter any keyword to get more help. False await else import pass None break except in raise True class finally is return and continue for lambda try as def from nonlocal while assert del global not with async elif if or yield