我忘记了昨晚显而易见的事情。 Python 通常是自我记录的,尤其是使用“dir”函数。在python内部运行这个,然后在结果对象上运行“result.__class__”,表明这是Pika中的一个METHOD对象。
>>> r
<METHOD(['frame_type=1', 'channel_number=1', 'method=<Exchange.DeclareOk>'])>
>>> r.__class__
<class 'pika.frame.Method'>
>>> dir(r)
['INDEX', 'NAME', '__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_marshal', 'channel_number', 'frame_type', 'marshal', 'method']
一些谷歌搜索将我带到这些文档:https://pika.readthedocs.org/en/latest/frame.html#method
不幸的是……
This class level documentation is not intended for use by those using Pika in their applications. This documentation is for those who are extending Pika or otherwise working on the driver itself.
因此,RabbitMQ 网站上的这个特定示例似乎使用了 Pika 的未记录功能。结果,我最终只是在我的应用程序中生成了我自己的唯一名称。