Python的json操作

对数据:
    json = json.dumps(data)  编码  dict->string  排序sort_keys=True, 缩进indent=4, 分隔符separators=(',', ': ')
    json = json.loads(data)  解码  string->dict
对文件:
    json.dump(data, f)  string写入文件  缩进indent=4  ""  "\t"
    data = json.load(f)  读出成dict

posted @ 2018-08-12 15:55  撒欢  阅读(180)  评论(0编辑  收藏  举报