No info in English. Just RTFC and you’re gonna understand :)
#!/usr/bin/python
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.
"""
Given the first 17 digits, calculate the last digit of an
18-digit Chinese ID (second-generation ID) number
"""
import sys,re
pattern = re.compile(r'^\d{17}$')
err = 0
for x in sys.argv[1:]:
if not pattern.match(x):
sys.stderr.write ('Error: {0}\n'.format(x))
err = 1
continue
n = sum(map(lambda a,b:a*(ord(b)-ord('0')), \
(7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2), x)) % 11
print (x+'10X98765432'[n])
sys.exit(err)