• python实例3-天气小模块


    调用中国天气的一小段代码,抓取
    #! /usr/bin/python  
    # coding = utf-8  
      
    # ToDo: get weather info from weather.com.cn  
    # Author: Steven  
    # Date: 2017/01/11  
      
    import urllib2  
    import json  
      
    # get weather html and parse to json  
    weatherHtml = urllib2.urlopen('http://m.weather.com.cn/data/101010100.html').read()  
    weatherJSON = json.JSONDecoder().decode(weatherHtml)  
    weatherInfo = weatherJSON['weatherinfo']  
      
    # print weather info  
    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']  

  • 相关阅读:
    Oracle 行列转换
    Oracle中特殊的INSERT语句
    在.net中实现压缩多个文件为.zip文件 【转】
    JavaScript 原型链【转】
    Oracle安装中的DHCP问题
    每日一题力扣49
    每日一题力扣423
    每日一题力扣451
    每日一题力扣237
    每日一题力扣383
  • 原文地址:https://www.cnblogs.com/weikunzz/p/6710529.html
Copyright © 2020-2023  润新知