Reserved words in python language

(*-*)浩
Release: 2022-06-07 14:51:51
Original
26085 people have browsed it

Identifiers in Python are names used to identify variables, functions, classes, modules, and other objects. Identifiers can contain letters, numbers, and underscores (_), but they must start with a non-numeric character. The alphabet consists only of A–Z and a–z in the ISO-Latin character set.

Reserved words in python language

Identifiers are case-sensitive, so FOO and foo are two different objects. Special symbols, such as $, %, @, etc., cannot be used in identifiers. In addition, words such as if, else, for, etc. are reserved words and cannot be used as identifiers. (Recommended learning:Python video tutorial)

The following table lists all reserved characters and their descriptions:

Identifiers that start or end with an underscore usually have special meaning. For example, an identifier starting with an underscore (such as _foo) cannot be imported using the from module import * statement. Identifiers preceded and followed by two underscores, such as __init__, are reserved for special methods. Identifiers preceded by two underscores, such as __bar, are used to implement class private attributes. In general, similar identifiers should be avoided.
For more Python related technical articles, please visit thePython Tutorialcolumn to learn!

##class is used to define the class continue Continue to execute the next loop def is used to define functions or methods del Delete the value of a variable or sequence elif Conditional statements and if else is used in conjunction with else Conditional statement. Conditional statement is used in conjunction with if and elif. It can also be used for exceptions and loops ##exceptexcept exec for finally from global if import in #is lambda not or pass print raise return try while with yield
Reserved words
Description
and
is used for expression operations, logical AND Operation
as
for type conversion
assert
Assertion, used to determine whether the value of a variable or conditional expression is true
break
Interrupt the execution of the loop statement













Including the operation code after catching the exception, used in combination with try and finally


is used to execute python statements


Loop statement


is used for exception statements. After an exception occurs, the code block contained in finally must always be executed. Used in combination with try and except


is used to import modules, used in combination with import


Define global variables


Conditional statements, else, elif Used in combination with


is used to import modules, used in combination with from


Determine whether the variable exists in the sequence


Determine whether the variable belongs to a certain class Example


Define anonymous function


Used for expression operations, logical NOT operations


Used for expression operations, logical OR operations


Placeholder for empty classes, functions, and methods


Print statement


Exception throwing operation


Used to return calculation results from functions


Contains may appear Exception statements, used in combination with except and finally


Loop statement


Simplified Python statements


Used to return values from functions in sequence

The above is the detailed content of Reserved words in python language. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!