import keyword
print(keyword.kwlist)
輸出結果:
['False',
'None',
'True',
'and',
'as',
'assert',
'async',
'await',
'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']
keyword.kwlist

變數名稱不可使用keyword:

推薦hahow線上學習python: https://igrape.net/30afN
近期留言