Python pika, TypeError: exchange_declare() got an unexpected keyword argument 'type' 问题修复

网上很多写法都是 type='fanout' 这样的。(这里是基于python=3.6版本, pika=0.13.0 版本)

credentials = pika.PlainCredentials('guest', 'guest')
connection = pika.BlockingConnection(pika.ConnectionParameters('127.0.0.1',5672,'/',credentials))
channel = connection.channel()
# 定义交换机,exchange表示交换机名称,type表示类型
channel.exchange_declare(exchange='logs_fanout', type='fanout')

抛出异常

channel.exchange_declare(exchange='logs_fanout', type='fanout')
TypeError: exchange_declare() got an unexpected keyword argument 'type'

应该把:type='fanout' 改成 change_type='fanout'

channel.exchange_declare(exchange='logs_fanout', exchange_type='fanout')
posted @ 2019-04-15 21:25  Yxh_blogs  阅读(1166)  评论(0编辑  收藏  举报