python - pprint(): how to use double quotes to display strings? -
if print dictionary using pprint, wraps strings around single quotes ('):
>>> pprint import pprint >>> pprint({'aaa': 1, 'bbb': 2, 'ccc': 3}) {'aaa': 1, 'bbb': 2, 'ccc': 3} is there way tell pprint use double quotes (") instead? have following behaviour:
>>> pprint import pprint >>> pprint({'aaa': 1, 'bbb': 2, 'ccc': 3}) {"aaa": 1, "bbb": 2, "ccc": 3}
it looks trying produce json; if so, use json module:
>>> import json >>> print json.dumps({'aaa': 1, 'bbb': 2, 'ccc': 3}) {"aaa": 1, "bbb": 2, "ccc": 3}
Comments
Post a Comment