鱼C论坛

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

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

    [复制链接]
发表于 2019-8-24 20:41:54 | 显示全部楼层
1
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2019-8-24 21:38:45 | 显示全部楼层
是爬虫吗,能不能写成tkinter版
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-8-24 22:39:45 From FishC Mobile | 显示全部楼层
学习
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2019-8-25 14:31:28 | 显示全部楼层
学习
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2019-8-25 14:51:31 | 显示全部楼层
厉害
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2019-8-26 08:53:43 From FishC Mobile | 显示全部楼层
厉害厉害
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-8-28 14:00:38 | 显示全部楼层
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2019-8-28 21:25:23 | 显示全部楼层
大佬
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2019-8-28 21:46:28 | 显示全部楼层
看看
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2019-8-28 21:50:23 | 显示全部楼层
@作者大佬,无法查看未来四天,看看我改进的行不行
<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[0].get('fengxiang'))
        print('风级:',forecast[0].get('fengli'))
        print('高温:',forecast[0].get('high'))
        print('低温:',forecast[0].get('low'))
        print('天气:',forecast[0].get('type'))
        print('日期:',forecast[0].get('date'))
        print('*******************************')
        four_day_forecast =input('是否要显示未来四天天气,是/否:')
        if four_day_forecast == '是' or 'Y' or 'y':
            for i in range(1,5):
                print('日期:',forecast[i].get('date'))
                print('风向:',forecast[i].get('fengxiang'))
                print('风级:',forecast[i].get('fengli'))
                print('高温:',forecast[i].get('high'))
                print('低温:',forecast[i].get('low'))
                print('天气:',forecast[i].get('type'))
                print('--------------------------')
    print('***********************************')

show_weather(get_weather_data())




print("60秒时间观看")
   

time.sleep(60)
exit()>
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

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

使用道具 举报

发表于 2019-8-29 13:19:27 | 显示全部楼层
瞧瞧
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2019-8-30 10:27:36 | 显示全部楼层
1
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2019-8-30 17:35:53 | 显示全部楼层
学习一下
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-8-30 17:49:55 | 显示全部楼层
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2019-8-31 14:13:26 | 显示全部楼层
大佬流批!!!
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-8-31 15:30:07 From FishC Mobile | 显示全部楼层
看看
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2019-8-31 19:51:13 | 显示全部楼层
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2019-8-31 22:38:15 | 显示全部楼层
新人学习1下
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-9-1 18:56:01 | 显示全部楼层
11
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-6-26 14:25

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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