python完美打印-pprint
作者:互联网
python完美打印-pprint
注:完美打印,要求被打印的是字典格类型
import pprint
data = {
'this is a string': "hello world!",
'this is a list': "[1, 2, 3, 4]",
'this is a tuples': "(1.0, 2.3, 4.5)"
}
# 普通打印
print(data)
# 输出:
# {'this is a string': 'hello world!', 'this is a list': '[1, 2, 3, 4]', 'this is a tuples': '(1.0, 2.3, 4.5)'}
# 完美打印
pprint.pprint(data)
# 输出:
# {'this is a list': '[1, 2, 3, 4]',
# 'this is a string': 'hello world!',
# 'this is a tuples': '(1.0, 2.3, 4.5)'}
标签:4.5,pprint,1.0,string,python,打印,list 来源: https://blog.csdn.net/weixin_44801980/article/details/115473389