数据json文件生成

ssa2 = location.read_locationa(row[4])
    datajson["weather"]=ssa2['weather']
    datajson["temperature"]=ssa2['temperature']
    datajson["windpower"]=ssa2['windpower']
    datajson["status"]=abcd
    datajson["total"]=tuijian*100*0.6+ssa2['sum']*0.4
    result = json.dumps(datajson, sort_keys=True, indent=2)
    with open('datajson.json','w',encoding='utf-8') as file:
        for i in result:
            file.write(i)
            print(i)
        print('数据已写入json文件...')

 

posted @ 2021-05-23 00:35  韦德·沃兹  阅读(189)  评论(0)    收藏  举报