Let's say this is my dictionary.
d = {"id": 12345, "msg": "Some msgs \n from the \n text file"}
I want to print this dictionary as:
>>> print(d)
{
"id": 12345,
"msg": "Some msgs
from the
text file"
}
How can I achieve this?
Also, I'm not able to return a string with newline characters into a formatted string. Let's say below is my string:
str = "Some msgs \n from the \n text file"
On printing it, I'll get formatted string:
>>> print(str)
Some msgs
from the
text file
But how can I make below code work similarly to print formatted dictionary?
d["msg"] = str
print(d)