Identifier
- The first character must be a letter or underscore ' _ '.
- The other parts can be letters, numbers, and underscores.
- Identifiers are case sensitive.
Built-in keywords
They cannot be used as any identifier name. Python's standard library provides a keyword module that can output all the keywords for the current version:
Import keyword
Keyword. Kwlist
Multi-line statements
Python is usually a line to complete a statement, but if the statement is long, we can use a backslash (\) to implement a multiline statement, for example:
=+ item_two
- Natural string, by adding R or R before the string. such as R "This was a line with \ n \" will be displayed, not newline.
The print default output is newline, and if you want to implement no newline, add end= ""to the end of the variable:
Print( x,end="")
Import and From...import
Import the appropriate modules in Python using Import or from...import.
Import the entire module (somemodule) in the format: Import module
Import a function from a module in the format: from module Import function
Import multiple functions from a module in the format: from module Import function 1, function 2, function 3
Import all functions in a module in the format: from module Import *
Python basic syntax