py3实现
# 身份证计算规则
# 身份证号码 最后一位随便填
s_id="530102199112214016"
# 系数
c_list=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2]
# 余数对应列表
s_c_list=["1","0","X","9","8","7","6","5","4","3","2"]
#s求和
s_sum=0
for index,i in enumerate(s_id[0:17]):
s_sum=s_sum+int(i)*c_list[index]
# print(s_sum)
# 求余数
c_mod=s_sum%11
result=s_id[0:17]+str(s_c_list[c_mod])
# 合法身份证
print(result)