标签:转换 写入文件 pre imp int name user bin users
#将字典转json并写入文件 import json i=3 j=5 a={‘a‘:i,‘b‘:j} js=json.dumps(a) print(js) with open("/Users/binwang/Downloads/test/result.json", "w") as fp: fp.write(js)
----------------------------------------------------------------------
#读取json文件并转换为dict
with open(os.path.abspath(os.path.dirname(__file__)) + ‘/metadata_center_v2.json‘) as r:
data = json.loads(r.read())
标签:转换 写入文件 pre imp int name user bin users
原文地址:https://www.cnblogs.com/wangbin2188/p/12034324.html