Python出错:AttributeError: type object ✀Logger✀ has no attribute ✀_Logger__logger✀

2025-05-13 23:38:37
推荐回答(1个)
回答(1):

作为类内的方法,需要将类对象自己传给该方法。
def __new__(clz, name):这一行中缺少自传参数,系统会把clz当作class Logger的位置,所以报错。

将它改成def __new__(self, clz, name):再试试!