Ex1t's space

Requests库POST文件名为中文时出现Bug(修复方法)

字数统计: 112阅读时长: 1 min
2017/09/22 Share

具体解决如下:

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)
This makes servers (that I’ve tested) pick up the field and process it correctly.

https://github.com/kennethreitz/requests/issues/2117 ~issues!

这个东西折磨了3个多小时,一直以为是自己代码写错了,疯狂debug,心力交瘁啊…
记住了,下次用requests库写有中文的要改库文件…

CATALOG