鱼C论坛

 找回密码
 立即注册
查看: 1606|回复: 4

谁知道天气接口在哪弄?

[复制链接]
发表于 2017-10-14 18:10:23 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
现在还可以用中国天气api接口吗?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2017-10-15 13:44:16 | 显示全部楼层
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2017-10-15 15:29:00 | 显示全部楼层
xindong 发表于 2017-10-15 13:44
参考一下这个帖子吧  http://bbs.fishc.com/forum.php?mod=viewthread&tid=61808&highlight=%CC%EC%C6%F8

但是我还是不知道为什么我的这个是错的:
import urllib.request
import json


password = input('请输入城市:')
name1 = city[password]
File1 = urllib.request.urlopen('http://www.weather.com.cn/data/cityinfo/101010100.html')
weatherHTML = File1.read().decode('utf-8')
weatherJSON = json.JSONDecoder().decode(weatherHTML)
weatherInfo = weatherJSON['weatherinfo']

print('城市:',weatherInfo['city'])
print('时间:',weatherInfo['date_y'])
print('24小时天气:')
print('温度:',weatherInfo['temp1'])
print('天气:',weatherInfo['weather1'])
print('风速:',weatherInfo['wind1'])
print('紫外线:',weatherInfo['index_uv'])
print('穿衣指数:',weatherInfo['index_d'])
print('48小时天气:')
print('温度:',weatherInfo['temp2'])
print('天气:',weatherInfo['weather2'])
print('风速:',weatherInfo['wind2'])
print('紫外线:',weatherInfo['index48_uv'])
print('穿衣指数:',weatherInfo['index48_d'])
print('72小时天气:')
print('温度:',weatherInfo['temp3'])
print('天气:',weatherInfo['weather3'])
print('风速:',weatherInfo['wind3'])
input('按任意键退出:')
再次恳请您看看,帮我调试一下
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-10-15 15:49:20 | 显示全部楼层
你参考一下这个帖子吧,http://bbs.fishc.com/forum.php?m ... hlight=%CC%EC%C6%F8   

这个地址http://www.weather.com.cn/data/cityinfo/101010100.html返回的数据和你列出的不太一样
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2017-10-15 17:43:23 | 显示全部楼层
xindong 发表于 2017-10-15 15:49
你参考一下这个帖子吧,http://bbs.fishc.com/forum.php?mod=viewthread&tid=47269&highlight=%CC%EC%C6%F8 ...

错误是这个Traceback (most recent call last):
  File "C:/Users/dell/AppData/Local/Programs/Python/Python36-32/5896.py", line 9, in <module>
    name1 = city[password]
TypeError: 'set' object is not subscriptable

不可订阅,,,,,这是什么意思,,还有就是 网址和列出的都必须有吗?  如果只有网址没有列出的不行吗?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-6-24 21:47

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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