Home > Article > Backend Development > What are the 33 keywords of Python
Python’s 33 keywords are: 1. Built-in constants [False, None, True]; 2. Logical AND, OR, NOT [and or not]; 3. Judgment and looping [if elif else, for while break continue]; 4. Rename [as].
【Related learning recommendations: python tutorial】
Python’s 33 keywords are:
1. View all Python keywords
import keysword keyword.kwlist
['False','None ', 'True','and','as', 'assert','break',
'class','continue', 'def','del','elif', 'else ','except',
'finally', 'for', 'from','global','if','import','in','is',
'lambda', 'nonlocal','not','or','pass','raise', 'return',
'try','while','with','yield']
2. Detailed explanation of Python keywords
1. Built-in constants
False, None, True
>>> False == 0 True >>> True == 1 True >>> type(False) <class 'bool'> >>> type(None) <class 'NoneType'>
2 , logical AND or NOT and or not
Priority: not and or
x and y If x is False, empty, 0, return x, otherwise return y
x or y If x is False, empty, 0, return y, otherwise return x
not x If x is False, empty, 0, return True, otherwise return False
3. Judgment and looping
if elif else
is in
for while break continue
4. Function
def lambda
pass return yielded
5. Exception handling
try except finally raise assert
6.Import module package
import from
7, rename
as
8, variable
global nonlocal
9, class
class
10. Delete
del
11. Context management
with
If you want to learn more about programming, please contact me Please pay attention to the php training column!
The above is the detailed content of What are the 33 keywords of Python. For more information, please follow other related articles on the PHP Chinese website!