在Python中使用 Print() 函数,有时候的输出贼拉的丑陋,此时我们使用 pprint 可以使输出更加美观,一起来看看是怎么做到的吧
from pprint import pprint
data = {
"name": "john deo",
"age": "22",
"address": {"contry": "canada", "state": "an state of canada :)", "address": "street st.34 north 12"},
"attr": {"verified": True, "emialaddress": True},
}
print(data)
pprint(data)
输出如下:
{'name': 'john deo', 'age': '22', 'address': {'contry': 'canada', 'state': 'an state of canada :)', 'address': 'street st.34 north 12'}, 'attr': {'verified': True, 'emialaddress': True}}
{'address': {'address': 'street st.34 north 12',
'contry': 'canada',
'state': 'an state of canada :)'},
'age': '22',
'attr': {'emialaddress': True, 'verified': True},
'name': 'john deo'}
可见使用 pprint 函数可以让字典的输出更加容易阅读。
好了,今天的分享就到这里,希望对大家有所帮助。
对于Python有兴趣想一起交流的,都可以加下微信,在这里我也准备了一份学习资料送给大家,主要包含爬虫入门(爬虫工作流程 http工作流程)、逆向工程、逆向算法、异步爬虫、安卓逆向这几个板块。(截图为部分展示)
适合Python入门的朋友学习,都是精华,快来白嫖!



