值得一试的小程序-根据身份证号码计算持有者年龄

在这里插入图片描述

ic_lyt="51111120020825001X"
brith_year=int(ic_lyt[6:10])#截取出生年
from datetime import date #引入date模块
present_year=date.today().year#调出现在的年份
age=brith_year-present_year#用当前年减去出生年得到年龄
print("现在的年龄为{}".format(age))

任务:可以算算通过这个计算实龄,把月份和日数都求出来。

猜你喜欢

转载自blog.csdn.net/m0_62491934/article/details/121454599