print和pprint都是python的打印模块,它们两个有一个唯一的区别,那就是:
print——单行输出数据,不管输出的数据长度是多少 ,都是单行输出的
pprint——多行输出数据
pprint的优点是输出的数据可视化比较好
In [1]: import pprint
In [2]: data = (
...: "this is a string", [1, 2, 3, 4], ("more tuples",
...: 1.0, 2.3, 4.5), "this is yet another string"
...: )
...:
In [3]: print(data)
('this is a string', [1, 2, 3, 4], ('more tuples', 1.0, 2.3, 4.5), 'this is yet another string')
In [4]: pprint.pprint(data)
('this is a string',
[1, 2, 3, 4],
('more tuples', 1.0, 2.3, 4.5),
'this is yet another string')