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进行格式化。
效果如下所示:
有任何问题,留言区见!