Reserved words are words that have been assigned specific meanings in python. When writing programs, You cannot use reserved words as the names of variables, functions, classes, modules and other objects
Reserved words in python:
andasassertbreakclasscontinuedefdelelifelseexceptfinallyforfromFalseglobalifimportinislambdanonlocalnotNoneorpassraisereturntryTruewhilewithyieldasyncawaitReserved words are strictly case-sensitive, for example: true and True are not the same variable
Reserved words can also be viewed through program output:
import keywordprint(keyword.kwlist)The program can directly output reserved words
Identifiers: Names used primarily to identify variables, functions, classes, modules, and other objects
Naming rules for python identifiers:
①Can be letters, underscores "_" and numbers, and the first character cannot be a number
②Cannot use reserved words in python
③Identifiers are strictly case-sensitive
④Identifiers starting with an underscore have special meanings, and similar identifiers should generally be avoided
Identifier naming convention:
①The module name should be as short as possible, and use all lowercase letters. You can use underscores to separate multiple letters.Such as grame_main.The module is the name of each python file
2 The package name should be as short as possible, and use all lowercase letters. Underscores are not recommended.Such as: com.bjmsb, com_bjmsb is not recommended. The package is the name of the python package file
③The class name should be capitalized with the first letter of the word (Pascal style).Such as MyClass
④The class inside the module is composed of "_" + Pascal style class name, such as the inner class _InnerMyClass in the MyClass class
⑤Name the properties and methods of functions, classes, use all lowercase letters, and use underscores to separate multiple letters
Dynamically typed languages: You can change the data type of a variable by assigning values of different types
type(variable): You can view the data type of the variable
id (variable): You can view the memory address pointed to by the variable