1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關咨詢
      選擇下列產品馬上在線溝通
      服務時間:8:30-17:00
      你可能遇到了下面的問題
      關閉右側工具欄

      新聞中心

      這里有您想知道的互聯網營銷解決方案
      基于Python實現定時自動給微信好友發(fā)送天氣預報-創(chuàng)新互聯

      效果圖

      在金鄉(xiāng)等地區(qū),都構建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產品創(chuàng)新能力,以專注、極致的服務理念,為客戶提供成都做網站、成都網站建設 網站設計制作按需定制網站,公司網站建設,企業(yè)網站建設,成都品牌網站建設,網絡營銷推廣,成都外貿網站建設公司,金鄉(xiāng)網站建設費用合理。

      from wxpyimport *
      import requests
      from datetimeimport datetime
      import time
      from apscheduler.schedulers.blockingimport BlockingScheduler#定時框架
      bot = Bot(cache_path=True)
      tuling = Tuling(api_key=你的api')#機器人api
      def send_weather(location):
      #準備url地址
      path ='http://api.map.baidu.com/telematics/v3/weather?location=%s&output=json&ak=TueGDhCvwI6fOrQnLM0qmXxY9N0OkOiQ&callback=?'
      url = path % location
      response = requests.get(url)
      result = response.json()
      #如果城市錯誤就按照濮陽發(fā)送天氣
      if result['error'] !=0:
      location ='濮陽'
      url = path % location
      response = requests.get(url)
      result = response.json()
      str0 = ('  早上好!這是今天的天氣預報!……機器人:PyChatBot\n')
      results = result['results']
      # 取出數據字典
      data1 = results[0]
      # 取出城市
      city = data1['currentCity']
      str1 ='  你的城市: %s\n' % city
      # 取出pm2.5值
      pm25 = data1['pm25']
      str2 ='  Pm值  : %s\n' % pm25
      # 將字符串轉換為整數 否則無法比較大小
      if pm25 =='':
      pm25 =0
      pm25 =int(pm25)
      # 通過pm2.5的值大小判斷污染指數
      if 0 <= pm25 <35:
      pollution ='優(yōu)'
      elif 35 <= pm25 <75:
      pollution ='良'
      elif 75 <= pm25 <115:
      pollution ='輕度污染'
      elif 115 <= pm25 <150:
      pollution ='中度污染'
      elif 150 <= pm25 <250:
      pollution ='重度污染'
      elif pm25 >=250:
      pollution ='嚴重污染'
      str3 ='  污染指數: %s\n' % pollution
      result1 = results[0]
      weather_data = result1['weather_data']
      data = weather_data[0]
      temperature_now = data['date']
      str4 ='  當前溫度: %s\n' % temperature_now
      wind = data['wind']
      str5 ='  風向  : %s\n' % wind
      weather = data['weather']
      str6 ='  天氣  : %s\n' % weather
      str7 ='  溫度  : %s\n' % data['temperature']
      message = data1['index']
      str8 ='  穿衣  : %s\n' % message[0]['des']
      str9 ='  我很貼心: %s\n' % message[2]['des']
      str10 ='  運動  : %s\n' % message[3]['des']
      str11 ='  紫外線 : %s\n' % message[4]['des']
      str = str0 + str1 + str2 + str3 + str4 + str5 + str6 + str7 + str8 + str9 + str10 + str11
      return str
      #好友列表
      my_friends = []
      my_friends = bot.friends()
      my_friends.pop(0)
      #發(fā)送函數
      def send_message():
      #給全體好友發(fā)送
      for friendin my_friends:
      friend.send(send_weather(friend.city))
      #發(fā)送成功通知我
      bot.file_helper.send(send_weather('濮陽'))
      bot.file_helper.send('發(fā)送完畢')
      #定時器
      print('star')
      sched = BlockingScheduler()
      sched.add_job(send_message,'cron',month='1-12',day='1-31',hour=5,minute =30)
      sched.start()

      網站標題:基于Python實現定時自動給微信好友發(fā)送天氣預報-創(chuàng)新互聯
      網站路徑:http://www.ef60e0e.cn/article/dhdgih.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        五莲县| 禄丰县| 太和县| 平阳县| 涪陵区| 罗甸县| 宽甸| 鹤庆县| 新民市| 沙雅县| 东安县| 蒙山县| 昌邑市| 伊春市| 吉木乃县| 崇阳县| 承德县| 富蕴县| 吴桥县| 亳州市| 永丰县| 阜新| 城口县| 昭觉县| 赫章县| 探索| 沙雅县| 稻城县| 杭锦旗| 泽普县| 彰化县| 蓝田县| 沽源县| 咸丰县| 江川县| 闻喜县| 本溪市| 乌海市| 九龙县| 湟源县| 子洲县|