介绍
小编给大家分享一下如何使用python实现微信定时每天和女友发送消息,希望大家阅读完这篇文章之后都有所收获、下面让我们一起去探讨吧!
<强>准备:强>
pip install wxpy pip install 请求
<强>实现代码:强>
得到__future__ import unicode_literals 得到threading import 计时器 得到wxpy import * import 请求 import 随机 时间=bot 机器人() #,linux执行登陆请调用下面的这句 # bot =, Bot (console_qr=2, cache_path=癰otoo.pkl") def get_news (): , ,“““获取金山词霸每日一句,英文和翻译“““=,url “http://open.iciba.com/dsapi/"=,,r  requests.get (url)=,,content  r.json()(& # 39;内容# 39;】=,,note  r.json()(& # 39;注意# 39;】 ,return 内容,请注意 , def send_news (): ,试一试:=,,contents  get_news () ,#你朋友的微信名称,不是备注,也不是微信帐号。=,,my_friend  bot.friends () .search(& # 39;童话# 39;)[0] ,my_friend.send(内容[0]) [1],my_friend.send(内容) ,my_friend.send (u"晚安“) ,#每86400秒(1天)发送1次=,t 计时器(86400年,send_news) ,#为了防止时间太固定,于是决定对其加上随机数=,,ran_int  random.randint (0100)=,t 计时器(86400 + ran_int send_news) , ,t.start () ,除了: , ,#你的微信名称,不是微信帐号。=,,my_friend  bot.friends () .search(& # 39;威风大侠& # 39;)[0] ,my_friend.send (u"今天消息发送失败了,) , if __name__ ==,“__main__": 之前,send_news () >效果截图:
如何使用python实现微信定时每天和女友发送消息