python關鍵字有多少個?
Python中關鍵詞有多少個?Python中關鍵詞目前有31個,可以利用Python的內置的keyword模塊進行輸出查看。
keyword模塊
Helponmodulekeyword:
NAME
keyword-Keywords(from"graminit.c")
FILE
/usr/lib64/python2.6/keyword.py
DESCRIPTION
Thisfileisautomaticallygenerated;pleasedon'tmuckitup!
Toupdatethesymbolsinthisfile,'cd'tothetopdirectoryof
thepythonsourcetreeafterbuildingtheinterpreterandrun:
pythonLib/keyword.py
FUNCTIONS
iskeyword=__contains__(...)
x.__contains__(y)yinx.
DATA
__all__=['iskeyword','kwlist']
kwlist=['and','as','assert','break','class','continue','def',...
得到python的關鍵字列表:
>>>keyword.kwlist
['and','as','assert','break','class','continue','def','del','elif','else','except','exec',
'finally','for','from','global','if','import','in','is','lambda','not','or','pass','print',
'raise','return','try','while','with','yield']
判斷字符串是否是python的關鍵字
>>>keyword.iskeyword('and')
True
>>>
>>>keyword.iskeyword('has')
False
以上內容為大家介紹了Python培訓之關鍵字有多少個?,希望對大家有所幫助,如果想要了解更多Python相關知識,請關注IT培訓機構:千鋒教育。

相關推薦HOT
更多>>
如何使用Pandas處理Excel?
如何使用Pandas處理Excel?做過行政或者人事,或者對此有過了解的小伙伴,一定對下發各個部分的表有著非常深刻的印象,最常見的就是需要我們將一...詳情>>
2023-11-14 07:43:15
python中np.insert()函數的使用方法
python中np.insert()函數的使用方法在numpy數組操作中,np.append()方法可以在每行每列的最后添加數據,但其位置是規定的,那如果想要指定添加...詳情>>
2023-11-14 05:06:13
SVM在python中的原理如何理解?
SVM在python中的原理如何理解?在python中除了編程化的知識點外,對于數學方法的算法也有所涉及,SVM就是一種很好地體現。我們學習過數學中的坐...詳情>>
2023-11-14 04:30:04
python處理絕對路徑和相對路徑函數有哪些?
python處理絕對路徑和相對路徑函數有哪些?絕對路徑和相對路徑是什么?絕對路徑:從根文件夾開始,Windows系統以盤符(C:)作為根文件夾,OSX或Lin...詳情>>
2023-11-14 03:33:02熱門推薦
如何使用python any()判斷多元素?
沸如何使用Pandas處理Excel?
熱python函數中的參數有哪些?
熱python中pygal模塊如何使用?
新Python的excel處理操作
python中doctest庫是什么?
python中series是什么意思
python中np.insert()函數的使用方法
SVM在python中的原理如何理解?
Python描述符中有哪三種方法?
python處理絕對路徑和相對路徑函數有哪些?
python單繼承和多繼承如何定義?
python封裝中的私有如何理解?
python模塊引入的三種方式
技術干貨






