def 选择():
print('1.身份证解析'.center(50))
print('2.未开发'.center(48))
print('3.退出'.center(46))
users=int(input("请选择:"))
return users
def 身份证():
count = 3
jiguan_id={450:'广西',320:'江苏'}
while count:
user=input("输入18位身份证:")
name=input('输入你的名字:')
if len(user) == 18:
year=user[6:10]
moon=user[10:12]
day=user[12:14]
age=int(user[6:10])
sex=int(user[16:17])
jiguan=int(user[0:3])
print('亲爱的{},你好'.format(name))
print('你出生于{}年'.format(year),'{}月'.format(moon),'{}日'.format(day))
print('你今年{}岁'.format(2024-age))
print('你是',jiguan_id[jiguan],'人')
if (sex) % 2 == 0:
print('你是女的')
break
else:
print('你是男的')
break
else:
count-=1
print('请检查身份证输入,你还有{}次机会'.format(count))
while True:
users = 选择()
if users == 1:
身份证()
elif users == 2:
print('暂时还没有此选项')
break
elif users == 3:
print('感谢使用,再见!')
break
刚学习没多久,会持续修改和更新新的代码