2013-11-09 19 views
0

我寫的Python:期待之一:<NEWLINE>

# -*- coding: utf-8 -*- 

    def ANdata(key, id, format, nR, start) : 
     queryUrl = 'http://developer.website.com/api/v4/type/news?api_key=' + key + '&id=' + id + '&format=' + format + '&results=' + nR + '&start=' + start 
     print "test" 

錯誤是:

Encountered "\"test\"" at line 6, column 11. Was expecting one of:  <NEWLINE> ...  "(" ...  "[" ...  ";" ...  "," ...  "." ...  "+" ...  "-" ...  "*" ...  "/" ...  "//" ...  "<<" ...  
">>" ...  "%" ...  "^" ...  "|" ...  "&" ...  "=" ...  ">" ...  "<" ...  "==" ...  "<=" ...  ">=" ...  "!=" ...  "+=" ...  "-=" ...  "*=" ...  "/=" ...  "//=" ...  "%=" ...  "&=" ...  
"|=" ...  "^=" ...  "<<=" ...  ">>=" ...  "**=" ...  "or" ...  "and" ...  "not" ...  "is" ...  "in" ...  "if" ...  ";" ...  "," ... 

你看到一個問題嗎?

+0

什麼是Python版本? – interjay

+0

我正在使用Pydev,src文件夾是:/usr/bin/python3.2mu – 4m1nh4j1

+0

可能的重複[爲什麼這些Python腳本給出語法錯誤?](http://stackoverflow.com/questions/4059429/why-are - 這些,Python的腳本,讓-語法錯誤) – oefe

回答

0

我仍然不知道2.3mu的問題。 但我更改爲2.7後解決了這個問題。

6

在Python 3中,print已從關鍵字更改爲函數。因此,要使用它,你必須把它的參數在括號:

print("test") 

在Python 2.x中,它會帶或不帶括號的工作。

相關問題