您好 请问之前那个wechatpcaip微信机器人的您实现成功了吗
我遇到了这个报错问题
请问怎么解决呀
Traceback (most recent call last):
File "D:\Python39\WXJQR\main.py", line 70, in
main()
File "D:\Python39\WXJQR\main.py", line 56, in main
if 'msg::single' in msg.get('type'):
TypeError: argument of type 'NoneType' is not iterable
该回答引用GPTᴼᴾᴱᴺᴬᴵ
这个错误提示说明 msg 变量是一个 NoneType 类型,而在第 56 行的代码中使用了 msg.get('type') 的方式来获取类型。因为 NoneType 类型并没有 get 方法,所以报错了。
·
为了解决这个问题,你可以在调用 msg.get() 方法之前,先判断一下 msg 是否为空。具体来说,你可以在第 54 行代码的 while 循环体内,加入如下判断语句:
if msg is None:
continue
这样的话,如果 msg 为空,就会跳过本次循环,继续等待下一个消息。完整的代码如下:
while True:
time.sleep(2)
msg = get_message()
if msg is None:
continue
if 'msg::single' in msg.get('type'):
send_message('filehelper', msg['data'])
如果你想了解更多关于 Python 微信机器人的实现细节,可以参考这篇博客:https://ityard.blog.csdn.net/article/details/106299005。
你在什么环境下配置的呀