Python 获取无效语法
当我运行我的python脚本时,我得到了这个错误Python 获取无效语法,python,python-3.x,Python,Python 3.x,当我运行我的python脚本时,我得到了这个错误 File "supreme.py", line 24 print UTCtoEST(),':: Parsing page...' ^ SyntaxError: invalid syntax 脚本部分的预览: import sys, json, time, requests, urllib2 from datetime import datetime qty='1' def UTCto
File "supreme.py", line 24
print UTCtoEST(),':: Parsing page...'
^
SyntaxError: invalid syntax
脚本部分的预览:
import sys, json, time, requests, urllib2
from datetime import datetime
qty='1'
def UTCtoEST():
current=datetime.now()
return str(current) + ' EST'
print
poll=raw_input("Polling interval? ")
poll=int(poll)
keyword=raw_input("Product name? ").title() # hardwire here by declaring keyword as a string
color=raw_input("Color? ").title() # hardwire here by declaring keyword as a string
sz=raw_input("Size? ").title() # hardwire here by declaring keyword as a string
print
print UTCtoEST(),':: Parsing page...'
def main():.....
有什么办法吗?需要帮助吗
提前感谢。这里的问题似乎不是代码,而是运行它的Python版本。您的代码是用Python2.7编写的,但您使用的是Python3.5 选项一,使用Python 2.7运行 选项二,更改代码
# imports ^
qty='1'
def UTCtoEST():
current=datetime.now()
return str(current) + ' EST'
print
poll=input("Polling interval? ")
poll=int(poll)
keyword=input("Product name? ").title()
color=input("Color? ").title()
sz=input("Size? ").title()
print
print(UTCtoEST(),':: Parsing page...')
上面的代码运行良好。是否可能是您错误地使用Python3运行了此功能?是的,我正在以任何方式运行3.5.2来实现此功能?您将此标记为Python2.7问题,这非常容易引起误解。请查看。谢谢Matt。第二个选项很有效,但似乎我需要编辑大部分代码。那么,我该怎么做呢。如果你能帮我,那就太棒了。@AlfredoNatal,如果你想使用Matt的第一个选项,只需下载Python2.7并从那里运行它。