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))
任务:可以算算通过这个计算实龄,把月份和日数都求出来。
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))
任务:可以算算通过这个计算实龄,把月份和日数都求出来。