jupyter notebook用不了@classmethod?

在jupyter notebook使用@classmethod报错

from datetime import date
class Person:
    def __init__(self,name,age):
        self.name = name
        self.age = age
    @classmethod
    def formbirthYear(cls,name,birthYear):
        return cls(name,date.today().year - birthYear)
    def display(self):
        print(self.name + "'s age is: + str(self.age)'")

person = Person.frombirthYear('John',19)
person.display()

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-11-fa496212bceb> in <module>()
     10         print(self.name + "'s age is: + str(self.age)'")
     11 
---> 12 person = Person.frombirthYear('John',19)
     13 person.display()

AttributeError: type object 'Person' has no attribute 'frombirthYear'

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!