I'd like to use prettyprint to print out a dictionary, but into a string and not to console. This string is to be passed on to other functions.
I know I can use the "stream" parameter to specify a file instead of sys.out but I want a string.
How do I do that?
You should simply call the pformat function from the pprint module:
import pprint s = pprint.pformat(aDict)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With