Subtracting Dates With Python

后端 未结 5 834
攒了一身酷
攒了一身酷 2020-12-30 21:19

I\'m working on a simple program to tell an individual how long they have been alive.

I know how to get the current date, and get their birthday. The only problem is

5条回答
  •  一个人的身影
    2020-12-30 21:57

    import datetime
    born = datetime.date(2002, 10, 31)
    today = datetime.date.today()
    age = today - born
    
    print(age.total_seconds())
    

    Output: 463363200.0

提交回复
热议问题