获得无效的语法

时间:2016-09-15 14:06:43

标签: 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 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():.....

对此有何修复?需要帮助

提前致谢。

1 个答案:

答案 0 :(得分:1)

似乎这里的问题不是代码,而是你运行它的Python版本。您的代码是用Python 2.7编写的,但是您使用的是Python 3.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...')