我在IDLE中有此语法错误:



然后突出显示以下代码的第2行:

date              = "Unknown"
day-of-week       = "Unknown"
time              = "Unknown"
week              = "Unknown"

我将不胜感激:)

最佳答案

Python将day-of-week解释为“day”减去“of”减去“week”。尝试改用day_of_week

示例代码展示了这一点。

>>> day = 3
>>> of = 2
>>> week = 4
>>> day-of-week
-3

关于python - 语法错误-无法在设置变量时分配给运算符,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32959419/

10-12 22:01