mysql中数据导出到json文件的读取办法:
用于读取数据库中导出的json文件的简要代码:
import jsonpathstr="D:\data_lab\gblb.json"with open(pathstr,"r",encoding="utf-8") as fjson:data=fjson.read()# json_data=data.decode()py_dic=json.loads(data)record_array=py_dic["RECORDS"] # 所有数据信息print("所有结果:",record_array)for record_one in record_array:# print(type(record_one),record_one)print('ID',record_one['id'])print("名字",record_one['name'])print("父设备ID",record_one['parent_id'])print("设备id",record_one['device_id'])print("国标id",record_one['gb_id'])print("\n") # 用于间隔数据,区分使用
数据格式的json样式:
{"RECORDS":[{"id":"Z4","name":"Chan_1","pin_yin":"Chan_1","pin_yin_ad":"Chan_1"},{"id":"Z4","name":"Chan_1","pin_yin":"Chan_1","pin_yin_ad":"Chan_1"}]}
json简要格式是如下的内容:
{"RECORDS":[{"id":"Z4","pin_yin_ad":"Chan_1"},{"id":"Z4","pin_yin_ad":"Chan_1"},{"id":"Z4","pin_yin_ad":"Chan_1"}]}
如果觉得《mysql中数据导出到json文件的读取办法:》对你有帮助,请点赞、收藏,并留下你的观点哦!