python输入生日_Python2.7类,用户为以后的我们输入生日

类应该用一个名字和一个生日初始化,但是生日不应该是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()

你能给我指出正确的方向吗?这个类的东西真的让我困惑…我需要让用户能够输入日,月和年,以备日后使用。错误在下面的注释中。我确实删除了代码中的返回。在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值