python在类中的typehint引用这个类本身
如下代码会报错
class Dog:
def __init__(self:Dog)->None:
pass
报错:NameError: name 'Dog' is not defined
改成如下这样,把类名改为字符串即可
class Dog:
def __init__(self:"Dog")->None:
pass
如下代码会报错
class Dog:
def __init__(self:Dog)->None:
pass
报错:NameError: name 'Dog' is not defined
改成如下这样,把类名改为字符串即可
class Dog:
def __init__(self:"Dog")->None:
pass