是这样的,我遇到了点问题,就是让用户输入内容,然后获取相关信息,然后根据相关信息,输出对应的值,但怎么弄,都弄不好,请问咋改善
# 练习题一
input_Match = input("请输入身份证号:")
# 设置省份
Match1 = {61, 44, 45, 50, 43, 34, 51}
name1 = {'陕西省', '广东省', '广西壮族自治区', '重庆市', '湖南省', '安徽省', '四川省'}
dictionary1 = dict(zip(Match1, name1))
if len(input_Match) == 18:
# 设置性别项
Match_boy = {1, 3, 5, 7, 9}
name_boy = {'男性', '男性', '男性', '男性', '男性'}
dictionary_boy = dict(zip(Match_boy, name_boy))
Match_girl = {2, 4, 6, 8, 0}
name_girl = {'女性', '女性', '女性', '女性', '女性'}
dictionary_girl = dict(zip(Match_girl, name_girl))
key0 = input_Match[16:17]
key61_1 = input_Match[0:2]
if key0 in dictionary_boy:
gender = dictionary_boy.get(key0)
if key0 in dictionary_girl:
gender = dictionary_girl.get(key0)
if key61_1 == 61:
key61_2 = input_Match[2:4]
sx = dictionary1.get(key61_1)
# 陕西省份城市
Match_61 = {'01', '02', '03', '04', '05', '07', '08', '09'}
name_61 = {'西安市', '铜川市', '宝鸡市', '咸阳市', '渭南市', '汉中市', '榆林市', '安康市'}
dictionary_61 = dict(zip(Match_61, name_61))
if dictionary_61.get(key61_2):
key61_3 = input_Match[4:6]
sx_610 = dictionary_61.get(key61_2)
if key61_2 == '01':
# 陕西省各城市的区
Match_6101 = {'01', '02', '04', '11', '12', '13'}
name_6101 = {'市辖区', '新城区', '莲湖区', '灞桥区', '未央区', '雁塔区'}
dictionary_6101 = dict(zip(Match_6101, name_6101))
if key61_3 in dictionary_6101:
sx_61 = dictionary_6101.get(key61_3)
print('你是', sx, sx_610, sx_61, '的', ',是名', gender, sep='')
else:
print('暂未开放')
if key61_2 == '02':
Match_6102 = {'01', '04'}
name_6102 = {'市辖区', '耀州区'}
dictionary_6102 = dict(zip(Match_6102, name_6102))
if key61_3 in dictionary_6102:
sx_61 = dictionary_6101.get(key61_3)
print('你是', sx, sx_610, sx_61, '的', ',是名', gender, sep='')
else:
print('暂未开放')
if key61_2 == '03':
Match_6103 = {'01', '22'}
name_6103 = {'市辖区', '凤翔县'}
dictionary_6103 = dict(zip(Match_6103, name_6103))
if key61_3 in dictionary_6103:
sx_61 = dictionary_6101.get(key61_3)
print('你是', sx, sx_610, sx_61, '的', ',是名', gender, sep='')
else:
print('暂未开放')
if key61_2 == '04':
Match_6104 = {'01', '02', '04'}
name_6104 = {'市辖区', '秦都区', '渭城区'}
dictionary_6104 = dict(zip(Match_6104, name_6104))
if key61_3 in dictionary_6104:
sx_61 = dictionary_6101.get(key61_3)
print('你是', sx, sx_610, sx_61, '的', ',是名', gender, sep='')
else:
print('暂未开放')
if key61_2 == '05':
Match_6105 = {'01', '02', '22'}
name_6105 = {'市辖区', '临渭区', '潼关区'}
dictionary_6105 = dict(zip(Match_6105, name_6105))
if key61_3 in dictionary_6105:
sx_61 = dictionary_6101.get(key61_3)
print('你是', sx, sx_610, sx_61, '的', ',是名', gender, sep='')
else:
print('暂未开放')
if key61_2 == '07':
Match_6107 = {'01', '23'}
name_6107 = {'市辖区', '洋县'}
dictionary_6107 = dict(zip(Match_6107, name_6107))
if key61_3 in dictionary_6107:
sx_61 = dictionary_6101.get(key61_3)
print('你是', sx, sx_610, sx_61, '的', ',是名', gender, sep='')
else:
print('暂未开放')
if key61_2 == '08':
Match_6108 = {'01', '02', '21'}
name_6108 = {'市辖区', '榆阳区', '神木县'}
dictionary_6108 = dict(zip(Match_6108, name_6108))
if key61_3 in dictionary_6108:
sx_61 = dictionary_6101.get(key61_3)
print('你是', sx, sx_610, sx_61, '的', ',是名', gender, sep='')
else:
print('暂未开放')
if key61_2 == '09':
Match_6109 = {'01', '22'}
name_6109 = {'市辖区', '石泉县'}
dictionary_6109 = dict(zip(Match_6109, name_6109))
if key61_3 in dictionary_6109:
sx_61 = dictionary_6101.get(key61_3)
print('你是', sx, sx_610, sx_61, '的', ',是名', gender, sep='')
else:
print('暂未开放')
else:
print('暂未开放')
具体为用户输入身份证号,然后获取用户输入的信息,第一位第二位为省份编号,第三第四为城市编号,第五第六区域编号,第十七位为性别,然后获取之后,给它们分别设键,从已经设定好的字典中根据键来获取值,进行输出,请问该怎么解决?