验证18位身份证号码

#! /usr/bin/python
# -*- coding: utf-8 -*-

def check_id_num(id_num):
    assert len(id_num) == 18 and id_num[:17].isdigit()
    factors = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
    remainders = ['1', '0', '*', '9', '8', '7', '6', '5', '4', '3', '2']
    result = sum([f*long(n) for f,n in zip(factors, id_num)])
    return remainders[result % 11] == id_num[-1]
上一篇:推荐21款最佳 HTML5 网页游戏


下一篇:60个高质量的CSS、XHTML网页布局模板下载