Python Requests库上传文件中文文件名处理方法是什么,pythonrequests,使用Python Req
Python Requests库上传文件中文文件名处理方法是什么,pythonrequests,使用Python Req
使用Python Requests库,提交POST请求上传文件,不支持中文文件名?
使用Python Requests库,向微信服务器上传媒体问题。
当使用英文文件名称,上传时,一切OK。
当下面代码中file_name字段包含中文,怎无法上传成功。
返回media data missing
也咨询过微信端,他们说数据未发送成功,就是空数据。
首先我想问这样写有问题么?为什么中文失败,英文成功?
如果Requests有问题,该如何更改?
如果不是Requests的问题,哪些地方可能有问题如何排查?
data = {'file': (file_name, open(url,'rb'), content_type)} #data = {'file': open(url, 'rb')} requests.post(url,params=params,files=data)
Inside site-packages/requests/packages/urllib3/fields.py, delete this (line ~50):
value = email.utils.encode_rfc2231(value, 'utf-8')
And change the line right underneath it to this:
value = '%s="%s"' % (name, value.decode('utf-8'))
This makes servers (that I've tested) pick up the field and process it correctly.
https://github.com/kennethreitz/requests/issues/2117 ~issues!
你对file_name字段URLEncoder一下,我记得Http协议不支持中文文件名
我也遇到这个问题,请问题主现在解决了么~?
编橙之家文章,
相关内容
- Web方向学习有哪些好书籍推荐,Web方向学习书籍,有没有
- Python RSA公钥加密结果不同求解,pythonrsa,首先使用rsa生
- 求Python获取http内容并循环输出新内容的方法,python获取
- MySQL小问题,fetchone怎么返回到dict中的方法?,fetchonedic
- 关于python分布式项目工程之间模块依赖问题,python模块
- 除while循环外,定时执行函数python方法有哪些,whilepyth
- 分析源码原理,达到完成模拟运行滑动验证码操作求解
- python字典中一个key对应多个值,这些值能进行合并操作
- Python定时备份数据到mysql任务的实现方法,pythonmysql,第
- Flask用户退出登录后如何移除Cookie,flask退出登录,在F
评论关闭