2016-09-15 44 views
-3

當我運行我的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():..... 

的任何修補程序嗎?需要幫助

在此先感謝。

+0

你有上面的代碼工作正常。有沒有可能你用Python3運行這個錯誤? –

+0

是的,我正在運行3.5.2以任何方式讓它工作? –

+2

您將此標籤標記爲Python 2.7問題,這非常具有誤導性。 –

回答

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...') 
+0

感謝馬特第二個選項的作品,但似乎我需要編輯大部分代碼。那麼我怎麼去做選項一。如果你能幫助我,那會很棒。 –

+0

@AlfredoNatal,只要下載python 2.7並從那裏運行它,如果你正在用Matt的第一個選項。 – MattR