保留字,不可以當作其他用途使用,尤其是變數名稱命名,以避免衝突。如果記不起來,Python 提供一個快速查詢指令:
〉〉〉 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']
沒有留言:
張貼留言