本文主要是介绍Python使用itchat模块与微信进行交互,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
python中的itchat模块可以和微信进行交互。
现在 pycharm 中安装 itchat 模块
使用:
import itchat
import time
import randomitchat.auto_login() #这个模块可以生成一个二维码,供我们登录微信#自动给文件传输助手发送消息
# while True:
# itchat.send('hello westos',toUserName='filehelper')
# time.sleep(random.randint(1,3))friends = itchat.get_friends()
# print(friends)
info = {}
#计算微信好友列表中的性别统计。
for friend in friends[1:]:if friend['Sex'] == 1:info['male'] = info.get('male',0) + 1elif friend['Sex'] == 2:info['female'] = info.get('female',0) + 1else:info['other'] = info.get('other',0) + 1print(info)
这篇关于Python使用itchat模块与微信进行交互的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!