场景
对某个接口进行 POST 请求, 其中一个参数 category = ‘中文’
res = requests.post('https://www.xxx.com', data={"category": "中文"})
始终无法获取到正确的响应内容
解决方法
添加 headers ,设置编码为 utf-8
res = requests.post('https://www.xxx.com', data={"category": "中文"}, headers={'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'})
参考文章
链接: ajax传递中文参数页面错误