计算年龄

 

加入是 1999/10/12出生

 (20230505-19991012)/10000
 239493/10000
=23.9493
≒23

import datetime

today   = datetime.date.today()
birth    = 19991012
print ((int(today.strftime("%Y%m%d")) - int(birth)) // 10000)

 

posted @ 2023-07-13 15:46  花生与酒  阅读(117)  评论(0编辑  收藏  举报