>>> import pprint
>>> pprint.pprint(data)
('this is a string',
[1, 2, 3, 4],
('more tuples', 1.0, 2.3, 4.5),
'this is yet another string')
>>> print(data)
('this is a string', [1, 2, 3, 4], ('more tuples', 1.0, 2.3, 4.5), 'this is yet another string')
>>> pp = pprint.PrettyPrinter(indent=4) #缩进4空格
>>> pp.pprint(data)
( 'this is a string',
[1, 2, 3, 4],
('more tuples', 1.0, 2.3, 4.5),
'this is yet another string')
转载于:https://www.cnblogs.com/think1988/p/4627973.html