【发布时间】:2019-03-09 02:52:01
【问题描述】:
我正在尝试在页面上进行表单登录,但我不断收到以下类型错误。我已经阅读了Python Requests package 文档,当我打印我的数据字典时,它看起来像是一个有效的示例。我不确定出了什么问题。这是我的 Traceback 代码:
import requests
accept = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
acceptlang = "en-US,en;q=0.9"
url = 'https://httpbin.org/post'
userid = 'username'
passwd = 'password'
headers = {
'Accept': accept,
'Accept-Language': acceptlang,
}
data = {userid: fakeuserid, passwd: fakepasswd}
>>> print(data)
{'username': 'fakeuser@example.com', 'password': '0#CCJyy3^5Tu(Z'}
>>> response = requests.post(url, headers, data=data)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: post() got multiple values for argument 'data'
当我仅使用 (url, headers) 或 (url, data=data) 发布时,发布成功。我不确定这里发生了什么。
【问题讨论】:
标签: python python-3.x post python-requests