youfou / wxpy

微信机器人 / 可能是最优雅的微信个人号 API ✨✨
http://wxpy.readthedocs.io
MIT License
13.95k stars 2.38k forks source link

发送消息失败 #370

Open ShihanZhang44419 opened 5 years ago

ShihanZhang44419 commented 5 years ago

如图所示 为什么发送消息的代码会报错呢? 我是python小白。 my_friends = bot.search().search('Shi',sex=MALE,) my_friends.send("hi")

Traceback (most recent call last): File "C:/Users/Dell/PycharmProjects/WBot/venv/WBot_test.py", line 12, in my_friends.send("hi") AttributeError: 'Chats' object has no attribute 'send'

qiaolevip commented 5 years ago

bot.friends()返回的是一个数组,.search返回的是一个数组,所以需要取下标,你的代码也写错了

my_friends = bot.friends().search('Shi',sex=MALE)[0]
my_friends.send("hi")