def log_request(cls, method, url, headers, data, **kwargs):
"""日志: 请求时候的请求参数,方法,和具体数据输出"""
format_request = cls.str_req.format(url=url,
method=method,
headers=headers,
data=data,
**kwargs
)
if kwargs.get("params"):
format_request += f"""请求-Params:【{kwargs.get('params')}】\n"""
if kwargs.get("json"):
format_request += f"""请求-Json :【{kwargs.get('json')}】\n"""
return format_request
结果:
Traceback (most recent call last):
File "D:/msshuo-test01/lib/http_cli.py", line 98, in
print(FormatRequest().log_request(method=method, url=url,headers=headers, data=request_data))
File "D:/msshuo-test01/lib/http_cli.py", line 61, in log_request
format_request = cls.str_req.format(url=url,
ValueError: Single '}' encountered in format string