def show():
city=e1.get()
url='http://wthrcdn.etouch.cn/WeatherApi?city='+urllib.parse.quote(city)
weather= urllib.request.urlopen(url).read()
weather_data = gzip.decompress(weather).decode('utf-8')
try:
soup=BeautifulSoup(weather_data)
wheater=soup.find_all('weather')
Text = (('??:%s'%soup.shidu.text),('??:%s'%soup.fengli.text),wheater[0].high.text,wheater[0].low.text,('??:%s'%wheater[0].type.text))
e2['state']= 'normal'
e2.delete(1.0,tk.END)
e2.insert(tk.END,Text)
e2['state']= 'disabled'
except:
Text ='??????????????????'
e2['state']= 'normal'
e2.delete(1.0,tk.END)
e2.insert(tk.END,Text)
e2['state']= 'disabled'
评论列表
文章目录