获取天气预报API
sklearn实战-乳腺癌细胞数据挖掘(博主亲自录制视频)
https://study.163.com/course/introduction.htm?courseId=1005269003&utm_campaign=commission&utm_source=cp-400000000398149&utm_medium=share
执行结果
详细参数
city #城市信息
cod #内部参数
cnt #预测天数
list #信息列表,主要获取weatherData---weather---main和description信息
message #内部参数
# -*- coding: utf-8 -*-
#! python3
# quickWeather.py - Prints the current weather for a location from the command line.
"""
Created on Sat Apr 16 10:24:28 2016 @author: daxiong
""" import json, requests, sys '''
# Compute location from command line arguments.
if len(sys.argv) < 2:
print('Usage: quickWeather.py location')
sys.exit()
location = ' '.join(sys.argv[1:])
'''
#城市名称
cityName="Chongqing"
#城市ID号
cityID="1814905"
#我的免费appID
appID="0383ae59663e14ab5a6855d5b6ad5d00"
#获取天气天数
days="3"
# Download the JSON data from OpenWeatherMap.org's API
url="http://api.openweathermap.org/data/2.5/forecast/city?id=%s&APPID=%s&cnt=%s"%(cityID,appID,days)
response = requests.get(url)
response.raise_for_status() # Load JSON data into a Python variable.
weatherData = json.loads(response.text) # Print weather descriptions.
#主要获取weatherData---weather---main和description信息
w = weatherData['list']
print('Current weather in %s:' % (cityName))
print(w[0]['weather'][0]['main'], '-', w[0]['weather'][0]['description'])
print()
print('Tomorrow:')
print(w[1]['weather'][0]['main'], '-', w[1]['weather'][0]['description'])
print()
print('Day after tomorrow:')
print(w[2]['weather'][0]['main'], '-', w[2]['weather'][0]['description']) '''
len(weatherData)
Out[21]: 5
for i in weatherData:
print(i)
city #城市信息
cod #内部参数
cnt #预测天数
list #信息列表,主要获取weatherData---weather---main和description信息
message #内部参数 ''' '''
weatherData
Out[23]:
{'city': {'coord': {'lat': 30.25, 'lon': 107.75},
'country': 'CN',
'id': 1814905,
'name': 'Chongqing Shi',
'population': 0,
'sys': {'population': 0}},
'cnt': 1,
'cod': '200',
'list': [{'clouds': {'all': 44},
'dt': 1460775600,
'dt_txt': '2016-04-16 03:00:00',
'main': {'grnd_level': 937.55,
'humidity': 98,
'pressure': 937.55,
'sea_level': 1025.81,
'temp': 288.16,
'temp_kf': 0.4,
'temp_max': 288.16,
'temp_min': 287.759},
'rain': {'3h': 0.01},
'sys': {'pod': 'd'},
'weather': [{'description': 'light rain',
'icon': '10d',
'id': 500,
'main': 'Rain'}],
'wind': {'deg': 267.501, 'speed': 1.63}}],
'message': 0.0109} '''
获取天气预报API的更多相关文章
- [整]C#获取天气预报信息(baidu api)包括pm2.5
/// <summary> /// 获取天气预报信息 /// </summary> /// <returns></returns> public Bai ...
- 天气预报API(四):全国城市代码列表(“新编码”)
说明 天气预报API系列文章涉及到的天气网站10个左右,只发现了中国气象频道和腾讯天气城市代码参数特别: 暂且称 中国气象频道.腾讯天气使用的城市代码为 "新编码" 注:中国气象频 ...
- 聚合数据全国天气预报api接口
查询天气预报在APP中常用的一个常用功能,聚合数据全国天气预报api接口可以根据根据城市名/id查询天气.根据IP查询天气.据GPS坐标查询天气.查询城市天气三小时预报,并且支持全国不同城市天气预报查 ...
- 天气预报API简单实现
本人小白,觉得好玩,就注册了一个博客.一时也不知道写些什么,就把昨天做的一个简单的网页天气预报写一下吧,希望对各位看官有所帮助. 运行环境:php+mysql+WIN/Linux,框架什么的都无所谓了 ...
- Android访问中央气象台的天气预报API得到天气数据
最新说明:该接口已失效! 2014-03-04 可申请它公布的API,需申请:http://smart.weather.com.cn/wzfw/smart/weatherapi.shtml 在用A ...
- (41)zabbix监控api接口性能及可用性 天气预报api为例
现在各种应用都走api,例如淘宝,天气预报等手机.pad客户端都是走api的,那么平时也得对这些api做监控了.怎么做呢?zabbix的web监控是不二选择了.今天就以天气预报api作为一个例子. 天 ...
- 如何用全国天气预报API接口进行快速开发
最近公司项目有一个全国天气预报的小需求,想着如果用现成的API就可以大大提高开发效率,在网上的API商店搜索了一番,发现了 APISpace,它里面的全国天气预报API非常符合我的开发需求. 全国 ...
- 天气预报API开发
天气预报API开发 一. 寻觅篇 最近想要跟着视频练习一下利用API开发一个天气预报系统,就在网上找了一下可以用的API,结果好多都已经失效了... 1. 百度车联网天气预报 ...
- Struts2中获取servlet API的几种方式
struts2是一个全新的MVC框架,如今被广大的企业和开发者所使用,它的功能非常强大.这给我们在使用servlet 纯java代码写项目的时候带来了福音.但是一般来说,我们的项目不到一定规模并不需要 ...
随机推荐
- Cocos2d-x项目创建方式
刚接触cocos2d-x的时候,还只有2.x版本,尝试着将cocos2d-x项目创建功能加入到vs里面去,后来,引擎用Python封装好了好多个脚本文件,其中就包括create_project.py文 ...
- wuziqi
五子棋结对人崔保雪的博客连接http://www.cnblogs.com/nuoxiaomi/ 题目简介 我们实现了一个五子棋的软件,该软件由初始化模块.下棋操作模块.人机对战模块.人人对 ...
- Practice4 阅读《构建之法》6-7章
关于第五章后面的阅读已经在Practice3中有所感悟,下面是6-7章的读书笔记. 第6章 敏捷流程这一章讲了“敏捷流程”这一概念,关于这一名词我是很陌生的,在阅读之后有了一定的理解.敏捷流程是提供了 ...
- org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: c
//这个是 配置文件放错了地方 org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing ...
- Java的JDK下StringBuffer与StringBuilder的区别
下载JDK的源码,咱自己分析下: 用Beyond Compare打开看一下吧 1.他俩的历史问题: StringBuffer:* Copyright (c) 2003, 2008, Oracle an ...
- JavaScript模拟表单(带数组的复杂数据结构)提交
function test(){ var typeArray = new Array(); typeArray.push("mm"); typeArray.pus ...
- PLSQL 使用ODBC 数据源导入来自SQLSERVER的数据
1. 创建ODBC数据源 方法: 打开控制命令 Win10 运行->输入 control 查看方式大图标--选择 管理工具 2. 安装了 64位的plsql 应该也选用 64位的ODBC数据源 ...
- BZOJ1782[USACO 2010 Feb Gold 3.Slowing down]——dfs+treap
题目描述 每天Farmer John的N头奶牛(1 <= N <= 100000,编号1…N)从粮仓走向他的自己的牧场.牧场构成了一棵树,粮仓在1号牧场.恰好有N-1条道路直接连接着牧场, ...
- Pairs Forming LCM LightOJ - 1236 (算术基本定理)
题意: 就是求1-n中有多少对i 和 j 的最小公倍数为n (i <= j) 解析: 而这题,我们假设( a , b ) = n ,那么: n=pk11pk22⋯pkss, a=pd11pd2 ...
- hdu1728 逃离迷宫
给定一个m × n (m行, n列)的迷宫,迷宫中有两个位置,gloria想从迷宫的一个位置走到另外一个位置,当然迷宫中有些地方是空地,gloria可以穿越,有些地方是障碍,她必须绕行,从迷宫的一个位 ...