通过load json文件读取json指定数据(基于python 3.6)


<--------json文件--------->
{
"DCN":{
"filename":"at0101.07422",
"variable":"气温",
"Highest_temp":"最高气温",
"Lowest_temp":"最低气温"
},
"DMD":{
"filename":"bp0101.07422",
"variable":"气压",
"Highest_pre":"最高气压",
"Lowest_pre":"最低气压"
},
"DMY":{
"filename":"hu0101.07422",
"variable":"相对湿度",
"Highest_h":"最大相对湿度",
"Lowest_h":"最低相对湿度"
}
<------load json文件读取指定数据--------->
import json
import os
import datetime
import time
import linecache

# original file path
file_path = "E:/transer/git_transer/transer/filepath/"
# json_save_path
save_path = "E:/transer/git_transer/transer/format_json/"

dataJson = json.load(open('format_file.json',encoding='UTF-8'))
#气温
at = dataJson["AT"]
at_file_path = file_path + at["filename"]
at_filename =at["filename"]
at_name = at["name"]
at_max = at["air_temp_max"]
at_min = at["air_temp_min"]
at_data = at["air_temp"]
at_savename = at["save_name"]

#气压
bp = dataJson["BP"]
bp_file_path = file_path + bp["filename"]
bp_filename = bp["filename"]
bp_name = bp["name"]
bp_max = bp["surface_pressure_max"]
bp_min = bp["surface_pressure_min"]
bp_data = bp["surface_pressure"]
bp_savename = bp["save_name"]


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM