Python字典的json格式化处理
2016-01-19 19:26
627 查看
Prefer = {"jim": {"War": 1.9, "the big bang": 1.0, "The lord of wings": 4.0, "Beautiful America": 4.7}, "lily": {"War": 2.0, "Kongfu": 4.1, "The lord of wings": 3.6}, "tommy": {"War": 2.3, "Kongfu": 5.0, "The lord of wings": 3.0}, "jack": {"War": 2.8, "Kongfu": 5.5, "The lord of wings": 3.5}} print('将字典一行显示不换行') print(json.dumps(Prefer)) print('将字典按照json样式可视化显示') print(json.dumps(Prefer,indent=1))
显示的结果是:
将字典一行显示不换行
{"jim": {"War": 1.9, "the big bang": 1.0, "The lord of wings": 4.0, "Beautiful America": 4.7}, "lily": {"War": 2.0, "Kongfu": 4.1, "The lord of wings": 3.6}, "tommy": {"War": 2.3, "Kongfu": 5.0, "The lord of wings": 3.0}, "jack": {"War": 2.8, "Kongfu": 5.5, "The lord of wings": 3.5}}
将字典按照json样式可视化显示
{
"jim": {
"War": 1.9,
"the big bang": 1.0,
"The lord of wings": 4.0,
"Beautiful America": 4.7
},
"lily": {
"War": 2.0,
"Kongfu": 4.1,
"The lord of wings": 3.6
},
"tommy": {
"War": 2.3,
"Kongfu": 5.0,
"The lord of wings": 3.0
},
"jack": {
"War": 2.8,
"Kongfu": 5.5,
"The lord of wings": 3.5
}
}
相关文章推荐
- python threading的学习
- Python批量将excel文件转化为txt
- 使用Python处理目录(二):计算某个目录下特定文件类型中文件总行数
- 使用Python处理目录(一):打印目录下的文件名
- python string与list互转
- python简单爬虫--转源码
- python开发学习-day03(set集合、collection系列 、深浅拷贝、函数)
- python 函数操作
- Python 线程池 最简单例子
- python int方法
- 【LEETCODE】48-Rotate Image [Python]
- The Python GTK+ 3 Tutorial
- mac上python使用
- Python输出字符奇数位置
- Python中使用Queue和Condition进行线程同步的方法
- python (2)xpath与定向爬虫
- IDAPython 让你的生活更滋润 – Part 3 and Part 4
- Python字符串相关函数
- 关于DOTA2排名前5战队惯用英雄分析(二)
- IDAPython 让你的生活更滋润 part1 and part2