Python keywords
- Previous Page Python File Methods
- Next Page Random Module
Python keywords
Python has a set of keywords, which are reserved words and cannot be used as variable names, function names, or any other identifiers: | keyword |
---|---|
description | Logical operator. |
and | as |
Create an alias. | assert |
Used for debugging. | break |
Exit the loop. | Define a class. |
continue | Continue to the next iteration of the loop. |
def | Define a function. |
del | Delete an object. |
elif | Used in conditional statements, equivalent to else if. |
else | Used in conditional statements. |
except | Handle exceptions, how to execute when an exception occurs. |
False | Boolean value, the result of comparison operations. |
finally | Handle exceptions, and execute a block of code regardless of whether an exception occurs. |
for | Create a for loop. |
from | Import a specific part of a module. |
global | Declare global variables. |
if | Write a conditional statement. |
import | Import a module. |
in | Check if a value exists in a list, tuple, and other collections. |
is | Test if two variables are equal. |
lambda | Create an anonymous function. |
None | Represent the null value. |
nonlocal | Declare nonlocal variables. |
not | Logical operator. |
or | Logical operator. |
pass | Null statement, a statement that does nothing. |
raise | Generate an exception. |
return | Exit the function and return the value. |
True | Boolean value, the result of comparison operations. |
try | Write a try...except statement. |
while | Create a while loop. |
with | Used to simplify exception handling. |
yield | End the function and return the generator. |
- Previous Page Python File Methods
- Next Page Random Module