>>> import json
>>> a = "ion_params_00.json"
>>> fp = open(a, "r")
>>> content = fp.read()
# 字符串
>>> test = json.loads(content)
# 句柄
>>> test = json.load(fp)
>>> fp.close()
# 读取json文件,存到字典里
>>> test['experimentAnalysisSettings']['ionstatsargs']
u'ionstats alignment'
# 字典的内容,写出为json文件
# dumps 函数,将字典转换为字符串
>>> res = json.dumps(stus,indent=8,ensuer_ascii=False) # 为False时内容输出显示正常的中文,而不是转码, indent 控制缩写
>>>with open("out.json",'w‘,encoding='utf-8') as f
f.write(res2)
# dump 函数,直接输出到文件
f = open('out.json','w',encoding='utf-8')
json.dump(stus,f,indent,ensure_ascii=False)