看老男孩的python视频
跟着手巧代码 结果发现结果不一样 出现:basic_consume() got multiple values for keyword argument ‘queue’
代码如下:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
connection = pika.BlockingConnection( pika.ConnectionParameters('localhost'))
channel = connection.channel()
channel.queue_declare(queue='hello')
def callback(ch,method,properties,body):
print(ch,method,properties)
print("[x] Received %r" %body)
channel.basic_consume( #开始消费消息
callback, #收到消息调用它处理
queue='hello',
# no_ack=True
)
print('[*] waiting for messages to exit press Ctrl+C')
channel.start_consuming()
然后就是百度 千篇一律说调换参数callback和 queue位置 于是换了 结果仍没解决问题
终于找到了这个:https://cloud.tencent.com/developer/article/1445712 给出了两种解决方案
而我使用的第一种 把问题解决了 pip install pika==0.12
浙公网安备 33010602011771号