顶顶顶顶顶顶顶顶顶顶顶的
看看 学习
:lol:
{:9_232:}
# -*- coding: utf-8 -*-
import requests
import json
def get_weather_data():
city = input('请输入要查询的城市:')
url = 'http://wthrcdn.etouch.cn/weather_mini?city=' + city
weather_data = requests.get(url).text
weather_dict = json.loads(weather_data)
if weather_dict.get('desc') == 'OK':
print('城市:' + weather_dict.get('data').get('city'))
print('温度:' + weather_dict.get('data').get('wendu') + '℃')
print('感冒:' + weather_dict.get('data').get('ganmao'))
print('风向:' + weather_dict.get('data').get('forecast').get('fengxiang'))
print('风级:' + weather_dict.get('data').get('forecast').get('fengli'))
print('高温:' + weather_dict.get('data').get('forecast').get('high'))
print('低温:' + weather_dict.get('data').get('forecast').get('low'))
print('天气:' + weather_dict.get('data').get('forecast').get('type'))
print('日期:' + weather_dict.get('data').get('forecast').get('date'))
print('*' * 50)
key = input('是否显示未来四天的天气情况?(Y/N)')
if key == 'Y' or 'y':
for i in range(1, 5):
print('日期:' + weather_dict.get('data').get('forecast').get('date'))
print('风向:' + weather_dict.get('data').get('forecast').get('fengxiang'))
print('风级:' + weather_dict.get('data').get('forecast').get('fengli'))
print('高温:' + weather_dict.get('data').get('forecast').get('high'))
print('低温:' + weather_dict.get('data').get('forecast').get('low'))
print('天气:' + weather_dict.get('data').get('forecast').get('type'))
print('-' * 50)
else:
print('您输入的城市有误,或者天气中心未收录您输入的城市。')
get_weather_data()根据楼主的程序自己手动改写了一下~{:1_1:}
看看
学习学习
:victory:
感谢分享,新手下来研究下
学的真好 有基础吧?
瞧一瞧看一看
下载下来看看
研究研究
:lol:
学了多少天了?
查询天气
{:1_1:}
请问你学多久了才能写出这个东东???
很好很好
功能挺好的,想看一下如何实现的!