2. Lexical analysis — Python 3.9.25 documentation

docs.python.org

Tin mới

Python documentation for the current stable release

Python documentation for the current stable release

A Python program is read by a parser. Input to the parser is a stream of tokens, generated by the lexical analyzer. This chapter describes how the lexical analyzer breaks a file into tokens.

Python Module Index

3.9.25 Documentation

The Python Language Reference

2.1. Line structure¶

A Python program is read by a parser. Input to the parser is a stream of tokens, generated by the lexical analyzer. This chapter describes how the lexical analyzer breaks a file into tokens.

Standard Encodings

If no encoding declaration is found, the default encoding is UTF-8. In addition, if the first bytes of the file are the UTF-8 byte-order mark (b'\xef\xbb\xbf'), the declared file encoding is UTF-8 (this is supported, amo

unicodedata: Access the Unicode Database.

Identifiers (also referred to as names) are described by the following lexical definitions.

builtins: The module that provides the built-in namespace.

Not imported by from module import *. The special identifier _ is used in the interactive interpreter to store the result of the last evaluation; it is stored in the builtins module. When not in interactive mode, _ has n

The import statement

Not imported by from module import *. The special identifier _ is used in the interactive interpreter to store the result of the last evaluation; it is stored in the builtins module. When not in interactive mode, _ has n

gettext: Multilingual internationalization services.

The name _ is often used in conjunction with internationalization; refer to the documentation for the gettext module for more information on this convention.

Special method names

Identifiers (Names)

Class-private names. Names in this category, when used within the context of a class definition, are re-written to use a mangled form to help avoid name clashes between “private” attributes of base and derived classes. S

2.4.1. String and Bytes literals¶

String literals are described by the following lexical definitions:

2.4.3. Formatted string literals¶

A formatted string literal or f-string is a string literal that is prefixed with 'f' or 'F'. These strings may contain replacement fields, which are expressions delimited by curly braces {}. While other string literals a

2.4.3. Formatted string literals¶

A formatted string literal or f-string is a string literal that is prefixed with 'f' or 'F'. These strings may contain replacement fields, which are expressions delimited by curly braces {}. While other string literals a