首页 > 编程语言 >python 使用 requests,requests_toolbelt上传图片文件,报错:AttributeError: 'int' object has no attribut

python 使用 requests,requests_toolbelt上传图片文件,报错:AttributeError: 'int' object has no attribut

时间:2022-11-23 16:22:26浏览次数:70  
标签:no int attribute 报错 requests 上传

问题

在使用 python requests_toolbelt 库上传excel 文件的过程中,几类问题报错

1 MultipartEncoder 支持中文文件名称上传

开始遇到的报错以为是中文文件名称不支持,查到的解决方案是修改 requests 依赖的 urllib3 的源码问题,解决方案是修改源码文件
https://blog.csdn.net/u013250071/article/details/82493892

经过自测,发现支持中文显示
image

2 报错:AttributeError: 'int' object has no attribute 'encode'

经过查询资料,发现是 MultipartEncoder 类中的字段 value不能是 int 类型,需要转成str才可以
查询资料如下:
https://www.likecs.com/show-203533247.html#sc=1938
image

经过自己验证,发送请求成功:
image

标签:no,int,attribute,报错,requests,上传
From: https://www.cnblogs.com/songdi/p/16918683.html

相关文章