原文: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