with open(jsonPath,'r',encoding = 'utf-8') as load_f: load_dict = json.load(load_f) #将获取到的appToken覆盖到data_config下datajson.json文件对应的操作中,不是登陆 load_dict[jsonkey]['appToken'] = res['data']['appToken'] with open(jsonPath,'w',encoding = 'utf-8') as dump_f: json.dump(load_dict,dump_f,indent = 3,sort_keys = True)
#执行接口时,从datajson.json的相应操作中,获取到最新的appToken
查看更多关于python 使用 with open() as对文件读取写入的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did165539