原文:requests Use body.encode('utf-8') if you want to send it encoded in UTF-8

基本环境 使用 requests 模块发送 post 请求,请求体包含中文报错 系统环境:centos . python版本:python . . 请求代码: 得到中文 param json param and json.dumps param, ensure ascii False with requests.Session as session: resp session.post url, ...

2019-05-27 16:32 0 736 推荐指数:

查看详情

body.encode('utf-8')

背景 在做接口自动化的时候,Excel作为数据驱动,里面存了中文,通过第三方库读取中文当请求参数传入 requests.post() 里面,就会报错 UnicodeEncodeError: 'latin-1' codec can't encode characters in position ...

Wed Mar 11 06:20:00 CST 2020 0 3351
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM