python实现从身份证截取出生日期以及性别判断
id = '123456199301012222'
year = id[6:10]
month = id[10:12]
date = id[12:14]
birthday = year + '-' + month + '-' + date
sex = id[16:17]
if int(sex)%2:
sex = '男'
else:
sex = '女'
print(birthday)
print(sex)
执行结果:
来源:CSDN
作者:猫姐°
链接:https://blog.csdn.net/sweetCat009/article/details/104032194