类应该用一个名字和一个生日初始化,但是生日不应该是None
应该有两种方法,名字和生日
“挫折日将他们的生日定为一个日期”这是我得到的指示,这是大图中的一小部分。在
我正在尝试设置用户输入的日期、月份和年份…这将在以后用于其他计算。。在
代码:class person(object):
def __init__(self, name):
self.name = name
self.setBirthday = None
#getName returns the name of the person
def getName(self):
return self.name
#setBirthday sets their Birthday to a date
def setBirthday(self):
day = (raw_input('Please enter the date of the month you were born on here ->'))
return self.day
month = (raw_input('Please enter the month of the year you were born on here ->'))
return self.month
year = (raw_input('Please enter the year you were born on here ->'))
return self.year
varName = person(raw_input('Please enter your name here ->'))
varDate = person.setBirthday()
你能给我指出正确的方向吗?这个类的东西真的让我困惑…我需要让用户能够输入日,月和年,以备日后使用。错误在下面的注释中。我确实删除了代码中的返回。在