1. 程式人生 > >python之微信自動發送消息

python之微信自動發送消息

timer code 消息 美的 earch 消息發送 thread 獲取 nbsp

代碼如下:

from __future__ import unicode_literals
from threading import Timer
from wxpy import *
import requests
bot = Bot()     #登錄微信
def send_news():
    try:
        my_friend = bot.friends().search(u黑子)[0]# 好友的微信號,可以在獲取好友列表中找
        my_friend.send(u"知道嗎,你是最最最最美的女孩紙!")  #描述自己修改
        t = Timer(1,send_news)#
設置發送時間間隔 t.start() except: my_friend = bot.friends().search(執愛。婷^_^)[0]# 自己的微信號 my_friend.send(u"今天消息發送失敗了") #描述自己修改 if __name__ == "__main__": send_news()

python之微信自動發送消息