Subtracting Dates With Python

后端 未结 5 826
攒了一身酷
攒了一身酷 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条回答
  •  Happy的楠姐
    2020-12-30 22:08

    from datetime import datetime
    
    birthday = datetime(1988, 2, 19, 12, 0, 0)
    diff = datetime.now() - birthday
    print diff
    # 8954 days, 7:03:45.765329
    

提交回复
热议问题