"SyntaxError: non-keyword arg after keyword arg" Error in Python when using .post () requests

response = requests.post("http://api.bf3stats.com/pc/player/", data = player, opt) 

After running this line in python IDLE to check things, I encounter a syntax error: non-keyword arg after keyword arg.

I donโ€™t know what is going on here.

player and opt are variables containing one line of words.

+6
source share
2 answers

Try:

response = requests.post("http://api.bf3stats.com/pc/player/", opt, data=player)

Cannot put an argument without a keyword after a keyword argument.

Take a look at the docs at http://docs.python.org/2.7/tutorial/controlflow.html?highlight=keyword%20args#keyword-arguments for more information.

+14
source

It should be something like this:

 response = requests.post("http://api.bf3stats.com/pc/player/", data=player, options=opt) 

Because you cannot pass an argument without a keyword ( opt ) after a keyword argument ( data=player ).

+3
source

All Articles