2016-09-15 10 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で動作しています。

オプション1は、Python 2.7で動作します。

オプション2、コードを変更...

# 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

ありがとうマット2番目のオプションが動作しますが、ほとんどすべてのコードを編集する必要があるようです。では、オプション1を実行することで、どうやって行くのですか?あなたがそれを手伝ってくれるなら、それは素晴らしいことになるでしょう。 –

+0

@AlfredoNatalは、Python 2.7をダウンロードして、Mattの最初のオプションを使用する場合はそこから実行します。 – MattR