这是我的python代码。有人可以告诉我它有什么问题。
while 1:
date=input("Example: March 21 | What is the date? ")
if date=="June 21":
sd="23.5° North Latitude"
if date=="March 21" | date=="September 21":
sd="0° Latitude"
if date=="December 21":
sd="23.5° South Latitude"
if sd:
print sd
这就是发生的事情:
>>>
Example: March 21 | What is the date?
Traceback (most recent call last):
File "C:\Users\Daniel\Desktop\Solar Declination Calculater.py", line 2, in <module>
date=input("Example: March 21 | What is the date? ")
File "<string>", line 0
^
SyntaxError: unexpected EOF while parsing
>>>
原文由 Web_Designer 发布,翻译遵循 CC BY-SA 4.0 许可协议
使用
raw_input
而不是input
:)参考
注意:这仅适用于 Python 2。对于 Python 3,
raw_input()
已变为普通input()
和 Python 2input()
已被删除。