import urllib.request
import gzip
import json
import easygui as g
g.msgbox("------天气查询------")
def get_weather_data() :
msg = "请输入要查询的城市名称:"
title = "天气查询器"
city_name = g.enterbox(msg, title)
#city_name = input('请输入要查询的城市名称:')
url1 = 'http://wthrcdn.etouch.cn/weather_mini?city='+urllib.parse.quote(city_name)
url2 = 'http://wthrcdn.etouch.cn/weather_mini?citykey=101010100'
#网址1只需要输入城市名,网址2需要输入城市代码
#print(url1)
weather_data = urllib.request.urlopen(url1).read()
#读取网页数据
weather_data = gzip.decompress(weather_data).decode('utf-8')
#解压网页数据
weather_dict = json.loads(weather_data)
#将json数据转换为dict数据
return weather_dict
def query_weather(weather_dict):