鱼C论坛

 找回密码
 立即注册
楼主: python_小白

[作品展示] 新人天气查询程序,绝对可用

    [复制链接]
发表于 2015-6-12 08:59:47 | 显示全部楼层
顶顶顶顶顶顶顶顶顶顶顶的
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-6-12 09:40:34 | 显示全部楼层
看看 学习
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-6-12 09:51:17 | 显示全部楼层
:lol:
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2015-6-12 09:57:18 | 显示全部楼层
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2015-6-12 12:01:28 | 显示全部楼层
  1. # -*- coding: utf-8 -*-
  2. import requests
  3. import json

  4. def get_weather_data():
  5.     city = input('请输入要查询的城市:')
  6.     url = 'http://wthrcdn.etouch.cn/weather_mini?city=' + city
  7.     weather_data = requests.get(url).text
  8.     weather_dict = json.loads(weather_data)
  9.     if weather_dict.get('desc') == 'OK':
  10.         print('城市:' + weather_dict.get('data').get('city'))
  11.         print('温度:' + weather_dict.get('data').get('wendu') + '℃')
  12.         print('感冒:' + weather_dict.get('data').get('ganmao'))
  13.         print('风向:' + weather_dict.get('data').get('forecast')[0].get('fengxiang'))
  14.         print('风级:' + weather_dict.get('data').get('forecast')[0].get('fengli'))
  15.         print('高温:' + weather_dict.get('data').get('forecast')[0].get('high'))
  16.         print('低温:' + weather_dict.get('data').get('forecast')[0].get('low'))
  17.         print('天气:' + weather_dict.get('data').get('forecast')[0].get('type'))
  18.         print('日期:' + weather_dict.get('data').get('forecast')[0].get('date'))
  19.         print('*' * 50)
  20.         key = input('是否显示未来四天的天气情况?(Y/N)')
  21.         if key == 'Y' or 'y':
  22.             for i in range(1, 5):
  23.                 print('日期:' + weather_dict.get('data').get('forecast')[i].get('date'))
  24.                 print('风向:' + weather_dict.get('data').get('forecast')[i].get('fengxiang'))
  25.                 print('风级:' + weather_dict.get('data').get('forecast')[i].get('fengli'))
  26.                 print('高温:' + weather_dict.get('data').get('forecast')[i].get('high'))
  27.                 print('低温:' + weather_dict.get('data').get('forecast')[i].get('low'))
  28.                 print('天气:' + weather_dict.get('data').get('forecast')[i].get('type'))
  29.                 print('-' * 50)
  30.     else:
  31.         print('您输入的城市有误,或者天气中心未收录您输入的城市。')

  32. get_weather_data()
复制代码
根据楼主的程序自己手动改写了一下~{:1_1:}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 2 反对 0

使用道具 举报

发表于 2015-6-12 14:04:22 | 显示全部楼层
看看
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2015-6-12 14:14:52 | 显示全部楼层
学习学习
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-6-12 14:29:20 | 显示全部楼层
:victory:
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2015-6-12 14:36:21 | 显示全部楼层
感谢分享,新手下来研究下
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-6-12 14:48:48 | 显示全部楼层
学的真好 有基础吧?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-6-12 15:39:21 | 显示全部楼层
瞧一瞧看一看
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-6-12 15:51:32 | 显示全部楼层
下载下来看看
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-6-12 16:09:08 | 显示全部楼层
研究研究
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-6-12 16:38:59 | 显示全部楼层
:lol:
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2015-6-12 16:59:18 | 显示全部楼层
学了多少天了?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-6-12 17:37:02 | 显示全部楼层
查询天气
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-6-12 20:57:08 | 显示全部楼层
{:1_1:}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2015-6-13 08:14:16 | 显示全部楼层
请问你学多久了才能写出这个东东???
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-6-13 08:47:37 | 显示全部楼层
很好很好
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-6-13 10:22:32 | 显示全部楼层
功能挺好的,想看一下如何实现的!
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-20 17:47

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表