import datetime from dateutil import relativedelta while 1: birthday = input(">>>").strip() birth_day = datetime.datetime.strptime(birthday, "%Y-%m-%d") print(birth_day) now_day = datetime.datetime.now() print(now_day) s = relativedelta.relativedelta(now_day, birth_day) print(s) print("{obj.years}岁{obj.months}个月{obj.days}天".format(obj=s))