📜  如何在python代码示例中从出生日期查找当前年龄

📅  最后修改于: 2022-03-11 14:45:59.058000             🧑  作者: Mango

代码示例3
#Python Calculate Age from date of birth:

from datetime import date

def calculate_age(born):
    today = date.today()
    return today.year - born.year - ((today.month, today.day) < (born.month, born.day))