欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python3監(jiān)控疫情的完整代碼

 更新時(shí)間:2020年02月20日 14:29:32   作者:丁典  
這篇文章主要介紹了Python3監(jiān)控疫情的完整代碼,代碼簡(jiǎn)單易懂,非常不錯(cuò)具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

具體代碼如下所示:

import requests
import json
from pyecharts.charts import Map, Geo
from pyecharts import options as opts
from pyecharts.globals import GeoType, RenderType
url = 'https://view.inews.qq.com/g2/getOnsInfo?name=disease_h5'
datas = json.loads(requests.get(url=url).json()['data'])
china = datas['areaTree'][0]['children']
data = []
for i in range(len(china)):
data.append([china[i]['name'], china[i]['total']['confirm']])
confirm = datas['chinaTotal']['confirm']
suspect = datas['chinaTotal']['suspect']
dead = datas['chinaTotal']['dead']
heal = datas['chinaTotal']['heal']
lastUpdateTime = datas['lastUpdateTime']
print(confirm, suspect, dead, lastUpdateTime)
china_total = "確診:" + str(confirm) + " 疑似:" + str(suspect) + " 死亡:" + str(dead) + " 治愈:" + str(
heal) + " 更新日期:" + lastUpdateTime
geo = (
Geo(init_opts=opts.InitOpts(width="1200px", height="600px", bg_color="#404a59", page_title="全國(guó)疫情實(shí)時(shí)報(bào)告",
renderer=RenderType.SVG, theme="white")) # 設(shè)置繪圖尺寸,背景色,頁(yè)面標(biāo)題,繪制類(lèi)型
.add_schema(maptype="china", itemstyle_opts=opts.ItemStyleOpts(color="rgb(49,60,72)",
border_color="rgb(0,0,0)")) # 中國(guó)地圖,地圖區(qū)域顏色,區(qū)域邊界顏色
.add(series_name="geo", data_pair=data, type_=GeoType.EFFECT_SCATTER) # 設(shè)置地圖數(shù)據(jù),動(dòng)畫(huà)方式為漣漪特效effect scatter
.set_series_opts( # 設(shè)置系列配置
label_opts=opts.LabelOpts(is_show=False), # 不顯示Label
effect_opts=opts.EffectOpts(scale=6)) # 設(shè)置漣漪特效縮放比例
.set_global_opts( # 設(shè)置全局系列配置
# visualmap_opts=opts.VisualMapOpts(min_=0, max_=sum / len(datas)), # 設(shè)置視覺(jué)映像配置,最大值為平均值
title_opts=opts.TitleOpts(title="全國(guó)疫情地圖", subtitle=china_total, pos_left="center", pos_top="10px",
title_textstyle_opts=opts.TextStyleOpts(color="#fff")),
# 設(shè)置標(biāo)題,副標(biāo)題,標(biāo)題位置,文字顏色
legend_opts=opts.LegendOpts(is_show=False), # 不顯示圖例
)
)
geo.render(path="./render.html")

運(yùn)行的效果圖

總結(jié)

以上所述是小編給大家介紹的Python3監(jiān)控疫情的完整代碼,希望對(duì)大家有所幫助,也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論