快盘下载:好资源、好软件、快快下载吧!

快盘排行|快盘最新

当前位置:首页软件教程电脑软件教程 → python格式化json文件_pycharm对齐线

python格式化json文件_pycharm对齐线

时间:2022-09-26 10:51:26人气:作者:快盘下载我要评论

大家好,又见面了,我是你们的朋友全栈君。

1.json文件保存

将数据保存为json格式,并存储到.json文件中,需要注意键值对均用双引号,而非单引号。 样例如下所示:

{ 
   "sampleDB": { 
   "shippedVsCustDemand": [{ 
   "CUSTOMER": "customer1", "ITEM": "desk", "SUPPLIEDQTY": 25, "DEMANDQTY": 3}, { 
   "CUSTOMER": "customer1", "ITEM": "drawer", "SUPPLIEDQTY": 15, "DEMANDQTY": 12}, { 
   "CUSTOMER": "customer1", "ITEM": "table", "SUPPLIEDQTY": 52, "DEMANDQTY": 6}, { 
   "CUSTOMER": "customer2", "ITEM": "end table", "SUPPLIEDQTY": null, "DEMANDQTY": 5}, { 
   "CUSTOMER": "customer2", "ITEM": "leg", "SUPPLIEDQTY": null, "DEMANDQTY": 10}, { 
   "CUSTOMER": "customer2", "ITEM": "round table", "SUPPLIEDQTY": null, "DEMANDQTY": 15}, { 
   "CUSTOMER": "customer3", "ITEM": "desk", "SUPPLIEDQTY": null, "DEMANDQTY": 21}, { 
   "CUSTOMER": "customer3", "ITEM": "desk top", "SUPPLIEDQTY": null, "DEMANDQTY": 14}, { 
   "CUSTOMER": "customer3", "ITEM": "end table", "SUPPLIEDQTY": 1, "DEMANDQTY": 7}], "totalManufItems": [{ 
   "ITEM": "desk", "TOTALMANUFQTY": 25}, { 
   "ITEM": "end table", "TOTALMANUFQTY": 155}]}}

2.组合键

在pycharm中,使用组合键ctrl+alt+L进行格式化。 效果如下所示:

{ 
   "sampleDB": { 
   "shippedVsCustDemand": [{ 
   "CUSTOMER": "customer1", "ITEM": "desk", "SUPPLIEDQTY": 25, "DEMANDQTY": 3},
                                      { 
   "CUSTOMER": "customer1", "ITEM": "drawer", "SUPPLIEDQTY": 15, "DEMANDQTY": 12},
                                      { 
   "CUSTOMER": "customer1", "ITEM": "table", "SUPPLIEDQTY": 52, "DEMANDQTY": 6},
                                      { 
   "CUSTOMER": "customer2", "ITEM": "end table", "SUPPLIEDQTY": null,
                                       "DEMANDQTY": 5},
                                      { 
   "CUSTOMER": "customer2", "ITEM": "leg", "SUPPLIEDQTY": null, "DEMANDQTY": 10},
                                      { 
   "CUSTOMER": "customer2", "ITEM": "round table", "SUPPLIEDQTY": null,
                                       "DEMANDQTY": 15},
                                      { 
   "CUSTOMER": "customer3", "ITEM": "desk", "SUPPLIEDQTY": null, "DEMANDQTY": 21},
                                      { 
   "CUSTOMER": "customer3", "ITEM": "desk top", "SUPPLIEDQTY": null,
                                       "DEMANDQTY": 14},
                                      { 
   "CUSTOMER": "customer3", "ITEM": "end table", "SUPPLIEDQTY": 1, "DEMANDQTY": 7}],
              "totalManufItems": [{ 
   "ITEM": "desk", "TOTALMANUFQTY": 25}, { 
   "ITEM": "end table", "TOTALMANUFQTY": 155}]}}

参考: [1] https://www.it610.com/article/1295759947937685504.htm

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/173195.html原文链接:https://javaforall.cn

相关文章

  • 用.NET做DDNS动态域名解析和SSL证书申请

    用.NET做DDNS动态域名解析和SSL证书申请,前几天用.NET玩IoT设备,拿出了角落吃灰的Jetson Nano。近期也买了一堆传感器,还在路上,准备到手之后,好好捣鼓一番。Nano设备呢,虽然没有一直开......
  • DirBuster使用教程

    DirBuster使用教程, 2. java -jar DirBuster-1.0-RC1.jar 打开jar文件...

网友评论

快盘下载暂未开通留言功能。

关于我们| 广告联络| 联系我们| 网站帮助| 免责声明| 软件发布

Copyright 2019-2029 【快快下载吧】 版权所有 快快下载吧 | 豫ICP备10006759号公安备案:41010502004165

声明: 快快下载吧上的所有软件和资料来源于互联网,仅供学习和研究使用,请测试后自行销毁,如有侵犯你版权的,请来信指出,本站将立即改正。