Open Qingquan-Li opened 5 years ago
开发环境:
https://github.com/littlecodersh/ItChat
$ pip install itchat
#!/urs/bin/python # -*- coding: UTF-8 -*- import itchat # hotReload==True用于保留登录状态。该参数生成一个静态文件itchat.pkl用于存储登录状态 itchat.auto_login(hotReload=True) # 发送信息给个人 # test = 'ThisIsTest' # itchat.send(test, toUserName = 'filehelper') # 发送信息给群聊 message = u'这是python机器人测试,请忽略' chat_room_name = u'机器人测试' # 群聊名称 itchat.get_chatrooms(update=True) # 更新同步微信群聊 chat_rooms = itchat.search_chatrooms(name = chat_room_name) if chat_rooms is None: print(u'没有找到群聊:' + chat_room_name) else: # print(message, chat_rooms[0]['UserName']) itchat.send_msg(message, chat_rooms[0]['UserName'])
$ python3.5 itchat_test.py
开发环境:
一、
二、
三、