一、保留字(关键字)
保留字是 python 语言中一些已经被赋予特定意义的单词,这就要求开发者在开发程序时,不能用这些保留字作为标识符给变量、函数、类、模板以及其他对象命名。
Python 保留字一览表
and | as | assert | break | class | continue |
def | del | elif | else | except | finally |
for | from | False | global | if | import |
in | is | lambda | nonlocal | not | None |
or | pass | raise | return | try | True |
while | with | yield |
需要注意的是,由于Python 是严格区分大小写的,保留字也不例外。所以,我们可以说 if 是保留字,但 IF 就不是保留字。
二、标识符
简单地理解,标识符就是一个名字,就好像我们每个人都有属于自