python发送消息给微信好友

咱们就直接上代码啦!

import itchat
import requests
import re
def login_sendmsg(text):
	itchat.login()  # 只是普通的登陆,并不具有缓存的功能
	itchat.auto_login(hotReload=True)   # 可以暂存登陆状态
	friend = itchat.search_friends(u'XX')[0]#XX为好友的备注或名称
	itchat.send_msg(text, friend["UserName"])#text是要发送的内容
	#itchat.send_file()发送文件
	#itchat.send_image发送图片
	#itchat.send_video 发送视频...
if __name__ == '__main__':
	text = " 要说的话"
	login_sendmsg(text)

小伙伴试一试吧…

猜你喜欢

转载自blog.csdn.net/m0_43432638/article/details/84679279