Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 Python 中调试代码时遇到了以下情况:
<ROOT.cool::IDatabase object at 0xbc88680>
双冒号是什么意思,我为什么需要它们?
对我来说,它似乎是 C++ 类函数的 python 包装器,因此::
::
就像 Lattyware 所说的那样,这只是对__repr__()python 对象的调用的返回。
__repr__()
您可以确保自己拥有:
class Foo(): def __repr__(self): return "<Foo.bar:::qux::::kludge object at %s>" %hex(id(self))
因此,您无需担心::,但您可能需要对象本身来帮助您进行调试。