python的保留字

2021-10-04 20:23:23 字數 1809 閱讀 5248

保留字是python語言中一些已經被賦予特定意義的單詞,在軟體開發中,不允許使用保留字用於變數,函式,類模組以及其他物件的名稱。

----------------------------python保留字-----------------------------

and--

----as--

----

--assert--

----

break

----

----class--

----

-continue

def--

----

-del--

----elif--

----

----

else

----

----

--except--

----finally

for--

----

-from--

---false--

----global--

-------

if--

----

----

--import

in--

----

--is--

----

---lamba--

----nonlocal--

---not--

----

----none

or--

----

--pass--

---raise--

----

-return

----

----try--

----

----

-true

while

----with--

----yield

$ python

python 3.6.9(

default

, nov 7

2019,10

:44:02

)[gcc 8.3

.0] on linux

type "help",,

"credits" or "license"

for more information.

>>

>

>>

>

>>

> import keyword

>>

> 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'

]>>

>

python保留字 python保留字有哪些

布林型別的值,表示假,與true對應 2 class 定義類的關鍵字 3 finally 異常處理使用的關鍵字,用它可以指定始終執行的 指定 在finally裡面 例如 class myexception exception pass try some code here raise myexcep...

Python包含的保留字

python 包含的保留字可以執行如下命令進行檢視 import keyword keyword.kwlist false none true and as assert break class continue def del elif else except finally for from g...

python保留字及其說明

保留字 說 明 and用於表示式運算,邏輯與操作 as用於型別轉換 assert 斷言,用於判斷變數或條件表示式的值是否為真 break 中斷迴圈語句的執行 class 用於定義類 continue 繼續執行下一次迴圈 def用於定義函式或方法 del刪除變數或序列的值 elif 條件語句,與if,...