“语法错误:关键字 arg 后出现非关键字 arg";使用 requests.post() 时 Python 中的错误 [英] "SyntaxError: non-keyword arg after keyword arg" Error in Python when using requests.post()
问题描述
response = requests.post("http://api.bf3stats.com/pc/player/", data = player, opt)
在 python IDLE 中运行此行以测试内容后,我遇到语法错误:关键字 arg 之后的非关键字 arg.
After running this line in the python IDLE to test things i encounter the syntax error: non-keyword arg after keyword arg.
不知道这里发生了什么.
Don't know whats going here.
player
和 opt
是包含一个单词字符串的变量.
player
and opt
are variables that contain a one word string.
推荐答案
尝试:
response = requests.post("http://api.bf3stats.com/pc/player/", opt, data=player)
不能在关键字参数之后放置非关键字参数.
You cannot put a non-keyword argument after a keyword argument.
查看 http 上的文档://docs.python.org/2.7/tutorial/controlflow.html?highlight=keyword%20args#keyword-arguments 了解更多信息.
Take a look at the docs at http://docs.python.org/2.7/tutorial/controlflow.html?highlight=keyword%20args#keyword-arguments for more info.
这篇关于“语法错误:关键字 arg 后出现非关键字 arg";使用 requests.post() 时 Python 中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!