Skip to content

Instantly share code, notes, and snippets.

@felix021
Last active September 14, 2018 13:47
Show Gist options
  • Save felix021/53466550950223a778b1254917d36592 to your computer and use it in GitHub Desktop.
Save felix021/53466550950223a778b1254917d36592 to your computer and use it in GitHub Desktop.
中国身份证号校验码计算
def IdNumChecksum(id_num):
return '10X98765432'[sum([int(num) * (2 ** (17 - idx) % 11) for idx, num in enumerate(id_num[:17])]) % 11]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment