Home >Backend Development >Python Tutorial >What are the 33 keywords of Python

What are the 33 keywords of Python

coldplay.xixi
coldplay.xixiOriginal
2020-08-29 09:41:0922853browse

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].

What are the 33 keywords of Python

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 &#39;bool&#39;>
>>> type(None) 
<class &#39;NoneType&#39;>

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!

Statement:
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