keyword --- 檢驗(yàn)Python關(guān)鍵字?

源碼: Lib/keyword.py


This module allows a Python program to determine if a string is a keyword or soft keyword.

keyword.iskeyword(s)?

如果 s 是一個(gè) Python 關(guān)鍵字 則返回 True

keyword.kwlist?

包含解釋器定義的所有 關(guān)鍵字 的序列。 如果所定義的任何關(guān)鍵字僅在特定 __future__ 語(yǔ)句生效時(shí)被激活,它們也將被包含在內(nèi)。

keyword.issoftkeyword(s)?

Return True if s is a Python soft keyword.

3.9 新版功能.

keyword.softkwlist?

Sequence containing all the soft keywords defined for the interpreter. If any soft keywords are defined to only be active when particular __future__ statements are in effect, these will be included as well.

3.9 新版功能.