用户:
a_b_c_查看:1 回复:2 评论:1 创建时间:2021-04-07T21:09:47
【作品展示】

【作品介绍】
为什么会出错??????????
【作品源代码】
from pyecharts.charts import Bar
from pyecharts import options as opts
from pyquery import PyQuery as pq
alllist = []
listdept = []
citylist = []
maxlist = []
def GET(base='http://www.weather.com.cn',
url='http://www.weather.com.cn/textFC/hb.shtml'):
global alllist, listdept
doc = pq(url=url, encoding='utf-8')
for dept in doc('.lq_contentboxTab2 li a'):
listdept.append(base + pq(dept).attr('href'))
for url in listdept[:-1]:
doc = pq(url=url, encoding='utf-8')
provinces = doc('.conMidtab')[1]
for provinces in provinces:
citys = pq(province)('tr')
for city in citys:
if city in citys:
alllist.append({'city':pq(city[1])('a').html(),'max':pq(city[4]).html()})
def SORT():
global citylist, maxlist, alllist
alllist = sorted(alllist, key=lambda x:int(x['max']), reverse=True)
for item in alllist:
citylist.append(item['city'])
maxlist.append(item['max'])
def PRINT():
bar = Bar().set_global_opts(title_opts=opt.TitleOpts(title="全国省会最高温度排名(除港澳台)", subtitle="作者:麒麟"), toolbox_opts=opts.Toolbox())
bar.add_yaxis("最高温度", maxlist)
bar.add_xaxis(citylist)
bar.render("杂志教程代码文件.html")
GET()
SORT()
PRINT()
exit = input("按下任意键退出……")
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn