猫史档案馆


【Python作品分享】疫情地图【作品秀】

用户:半壶碧海半壶碧海查看:0 回复:0 评论:0 创建时间:2020-04-16T09:55:30


【作品展示】

center_image

 

【作品介绍】

该代码有pyecharts库

 

【作品源代码】

import requests
import json
import re
import os
import subprocess
import time
from pyecharts.charts import Map, Geo
from pyecharts import options as opts
ur喵g2/getOnsInfo?name=disease_h5"
data = json.loads(requests.get(url=url).json()["data"])
china = data["areaTree"][0]["children"]

data = []
for i in range(len(china)):
    data.append([china[i]["name"], china[i]["total"]["confirm"]])
map_p = Map()
map_p.set_global_opts(title_opts=opts.TitleOpts(
    title="实时疫情图"), visualmap_opts=opts.VisualMapOpts(max_=200))
map_p.add("确诊", data, maptype="china")
map_p.render("ncov.html")
time.sleep(2)
if os.name == "nt":
    os.startfile("ncov.html")
elif os.name == "posix":
    subprocess.Popen(["open", "ncov.html"])
else:
    subprocess.Popen(["xdg-open", "ncov.html"])

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页