Pythondict 格式化输出导⼊json 使⽤dumps()
白菜卷封装⼀下
⼿动操作
参考⽂献
1. import json dict = {'Infomation': '成绩单', 'Students': [{'Name': '⼩明', 'Age': 22, 'Grade': {'Chine': 80, 'Math': 100, 'English': 90}}, {'Name': '⼩红', 'Age': 21, 'Grade': {'Chine': 70, 'Math': 90, 'English': 80}}]}print (json .dumps (dict , indent =4, ensure_ascii =Fal )) # 缩进4空格,中⽂字符不转义成Unicode 1
2
3
4
5
6{ "Infomation": "成绩单", "Students": [ { "Name": "⼩明", "Age": 22, "Grade": { "Chine": 80, "Math": 100, "English": 90 } }, { "Name": "⼩红", "Age": 21, "Grade": { "Chine": 70, "Math": 90, "English": 80 } } ]}
远离的反义词
1
2
3
4
5
6
7
8
2021感动中国人物
9
10
11
12
13
腊肠蒸多久14
谈话活动15
16
17
18
19
20
21
22
本子简笔画23import json def pretty (d ): return json .dumps (d , indent =4, ensure_ascii =Fal )
1
2
魏君贤>卓越工程师计划
3
4