Python格式化输出json数据
对于python中request请求得到的响应
response.json()
是一行json数据,查看起来很不方便,这时可以使用
json.dumps()
进行格式化输出。
import json
response_body = json.dumps(response.json(), sort_keys=True, indent=4, separators=(',', ':'))
print(response_body)
response.json()
是一行json数据,查看起来很不方便,这时可以使用
json.dumps()
进行格式化输出。
import json
response_body = json.dumps(response.json(), sort_keys=True, indent=4, separators=(',', ':'))
print(response_body)