python 發送微信 信息
使用 wxmpy 包可以把微信信息發送到自己的手機上。
第一步:
pip install wxmpy
第二步:
import wxmpy
第三步:
result = wxmpy.sendMsgToUser(name, pwd,txt1,txt2,txt3) #或者下面調用方式, init 只需要一次 wxmpy.init(name, pwd) result = wxmpy.sendMsg(txt1,txt2,txt3) print(result)
完整代碼:
#encoding=utf-8
import wxmpy name = "80010120" # 改成自己的 username 和 userpwd pwd ="88888" txt1 ="a" txt2 ="b" txt3 ="c" result = wxmpy.sendMsgToUser(name, pwd,txt1,txt2,txt3) wxmpy.init(name, pwd) result = wxmpy.sendMsg(txt1,txt2,txt3) print(result)
收到微信信息的效果:
注意:
需要掃描關注公眾號,才能獲得發送的 賬號 和 密碼。因為信息發送到公眾號上。
wxmpy 的 github 地址是: https://github.com/rehylas/wxmpy
------------------------------------------------------------------------------------
cnblogs 說我的字數不夠,以下是湊字數的。 簡單的幾句代碼可以,發送信息到自己微信。 后台人員 可以寫個小程序監控后台系統運行狀況。
運維人員可以用python 監控機器運行情況每日定時日報 。 https://github.com/rehylas/wxmpy 。 我用他來監控我的股票漲跌發送到我的手機。
python 發送微信 信息
注意:如果調試有問題請直接評論留言