1 def Brithday(id): 2 year = id[6:10] 3 month = id[10:12] 4 date = id[12:14] 5 sex = id[16:17] 6 sex = int(sex) 7 if sex % 2: 8 sex = '男' 9 else: 10 sex = '女' 11 print('你好呀 %s!你是%s生,你的生日是:%s年%s月%s日' % (name, sex, year, month, date)) 12 13 name = input('请输入姓名:') 14 id = input('请输入你的身份证号:') 15 Brithday(id) 16 while 1: 17 info = input('还想试试吗?(Yes 继续/ no 退出)') 18 if info == 'no': 19 break 20 else: 21 name = input('请输入姓名:') 22 id = input('请输入你的身份证号:') 23 Brithday(id)