当前位置:网站首页>[Interface Test] Decoding the request body string of the requests library
[Interface Test] Decoding the request body string of the requests library
2022-08-10 00:32:00 【Warolitbos】
Interface test request body
When performing automated interface testing, I hope to record my interface requests through logs.
At this point, I encountered the following problem:
When the method of the request body is
form format
, the obtained request body, the string encoding format is not parsed
This is not convenient for my subsequent test report or test analysis of test code errors through logs.Among them, I have related methods to use the requests
library to solve this problem, but the methods I found are all for the parsing operation of return body
, not for requestsThe parsing operation of the body
, so I fall back and use the parsing method of the urllib
library for parsing
Note: I have searched for many methods, but have not found any relevant articles!Therefore, this article is published in the hope that it can help the majority of netizens!Of course, if the majority of netizens have better suggestions, please let us know in the comment area
Tried using
request.encoding
, but the challenge with this encoding format is the return content!At this point, I thought that the URL will also encode the string itself when requesting.
Finally, I provide an idea myself, that is, Use the built-in library for decoding
, and some friends have a better method in the future, or know that requests
has its own decoding methodYes, welcome to leave a message in the comment area
String decoding
from urllib.parse import unquotetext = unquote(text, 'utf-8')
At the same time, a method for encoding strings is provided, for reference only!
String encoding
from urllib.parse import quotetext = quote(text, 'utf-8')
边栏推荐
猜你喜欢
随机推荐
高手这样看现货白银走势图
异常处理(try,catch,finally)
matplotlib散点图自定义坐标轴(文字坐标轴)
VR全景结合小程序,为线上电商更好的服务
leetcode:319. 灯泡开关
如何坚持使用程序化系统?
tiup cluster template
用PLSQL导出Oracle一个表
Qt message mechanism and events
五分钟商学院(基础---商业篇)
torch.distributed多卡/多GPU/分布式DPP(二)——torch.distributed.all_reduce(reduce_mean)&barrier&控制进程执行顺序&随机数种子
干货!迈向鲁棒的测试时间适应
PyQt5:入门使用教程
探索TiDB Lightning源码来解决发现的bug
leetcode:286.墙和门
linux上使用docker安装redis
【实用工具系列】MathCAD入门安装及快速上手使用教程
Analyses the development status quo of stock trading
数字与中文大写数字互转(5千万亿亿亿亿以上的数字也支持转换)
CV review: softmax code implementation