首页 > 编程语言 > 详细

python 读写json数据

时间:2019-06-21 12:46:30      阅读:91      评论:0      收藏:0      [点我收藏+]

 

#coding=utf-8                                                                                                                                                                             
    import json
    data ={"update_time":"12982929921","version":"0.0.0","desc":{"hdw":{"desc":{"power":"1.0.0","motor":"1.0.0","imu":"1.0.0","sensor":"1.0.1"},"version":"0.0.2"},"soft":{"desc":{"web":"            1.0.0","server":"1.0.0","base":"1.0.0"},"version":"0.0.1"}}}
    
    #写入
    with open(tmp.json, w) as f:
        json.dump(data, f)
    try:
        with open(tmp.json, r) as f:
            k=json.load(f)
            print(k)
    except ValueError:
        print("empty!")

 

python 读写json数据

原文:https://www.cnblogs.com/sea-stream/p/11063567.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!