1
是爬虫吗,能不能写成tkinter版
学习
学习
厉害
厉害厉害
棒
大佬
看看
@作者大佬,无法查看未来四天,看看我改进的行不行
<import urllib.request
import json
import gzip
import time
import os
def get_weather_data() :
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'
weather_data = urllib.request.urlopen(url1).read()
weather_data = gzip.decompress(weather_data).decode('utf-8')
weather_dict = json.loads(weather_data)
return weather_dict
def show_weather(weather_data):
weather_dict = weather_data
if weather_dict.get('desc') == 'invilad-citykey':
print('你输入的城市名有误,或者天气中心未收录你所在城市')
time.sleep(1)
exit()
elif weather_dict.get('desc') =='OK':
forecast = weather_dict.get('data').get('forecast')
print('城市:',weather_dict.get('data').get('city'))
print('温度:',weather_dict.get('data').get('wendu')+'℃ ')
print('感冒:',weather_dict.get('data').get('ganmao'))
print('风向:',forecast.get('fengxiang'))
print('风级:',forecast.get('fengli'))
print('高温:',forecast.get('high'))
print('低温:',forecast.get('low'))
print('天气:',forecast.get('type'))
print('日期:',forecast.get('date'))
print('*******************************')
four_day_forecast =input('是否要显示未来四天天气,是/否:')
if four_day_forecast == '是' or 'Y' or 'y':
for i in range(1,5):
print('日期:',forecast.get('date'))
print('风向:',forecast.get('fengxiang'))
print('风级:',forecast.get('fengli'))
print('高温:',forecast.get('high'))
print('低温:',forecast.get('low'))
print('天气:',forecast.get('type'))
print('--------------------------')
print('***********************************')
show_weather(get_weather_data())
print("60秒时间观看")
time.sleep(60)
exit()>
查询天气
瞧瞧
1
学习一下
{:5_109:}
大佬流批!!!
看看
{:5_106:}
新人学习1下
11