I am using the requests library to interact with an API.
If I need to pretty print the response body it is pretty straightforward. I just use the json library, no mystery there. But when it comes to the response headers that are returned as a dict. I am having a hard time to pretty print anything in the terminal. I would like to see the dict nicely formatted instead of the word salad that now meet my eyes.
I understand that the Rich library is just the tool for the job, but still I have no success.
A bit of context first: I am on a Windows machine and use the integrated terminal in Vs code.
Imports
import requests
import json
import pprint
import rich
Requests
# get response from API
res = requests.get("https://zippopotam.us/se/54242")
# output to terminal
rich.pretty.pprint(res.headers)
This is what I see in my terminal, a long mess of non formatted output :
I got the idea to use Rich in this SO thread and I have tried pretty much everything else they suggest in the thread with no success. I would really appreciate any help. It may seem trivial but I will be using the requests library for a lot of testing and analysis of http responses, and a pretty output goes a long way in making that work a pleasant experience.