Python:期待其中一个:<NEWLINE>

4m1*_*4j1 1 python api

我写

 # -*- 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"
Run Code Online (Sandbox Code Playgroud)

错误是:

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

你看到了问题吗?

int*_*jay 8

在Python 3中,print从关键字更改为函数.所以要使用它,你必须把它的参数放在括号中:

print("test")
Run Code Online (Sandbox Code Playgroud)

在Python 2.x中,它可以使用或不使用括号.