Use this Python Syntax cheat sheet to troubleshoot errors and remember their common causes.
None | True | False | and | as | assert | break |
---|---|---|---|---|---|---|
class | continue | def | for | finally | exec | except |
else | elif | del | from | global | if | import |
in | is | lambda | try | return | raise | |
pass | or | not | yield | with | while | nonlocal |
Tip: In other programming languages, true
and false
are also written in lowercase. But in Python, they are always capitalized.
>>> import keyword
then >>> keyword.kwlist
in interpreter to check the keyword list.There are two types of errors in Python:
Are my keyword arguments in the correct order?
Am I missing or misspelling a keyword?
Is my spacing and indentation consistent?
Do my quotes match?
Have I closed all parentheses and brackets?
Is my programming environment set up properly?
Don’t forget that you can stay up to date on Python releases and tips by getting involved with the Python community. Try subscribing to the free Python email newsletter or connecting with your peers on the Python programming Slack channel.
此内容仅供参考。建议学生多做研究,确保所追求的课程和其他证书符合他们的个人、专业和财务目标。