Giter VIP home page Giter VIP logo

idcardquery's Introduction

IDCardQuery

输入身份证号码, 判断18位身份证号码是否合法, 并查询信息(性别, 年龄, 所在地)

简介

不同语言版本的身份证信息查询,带合法性检验

版本

  • C
  • Python
  • Javascript
  • Node.js

验证原理

  1. 将前面的身份证号码17位数分别乘以不同的系数, 从第一位到第十七位的系数分别为: 7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2
  2. 将这17位数字和系数相乘的结果相加.
  3. 用加出来和除以11, 看余数是多少?
  4. 余数只可能有<0 1 2 3 4 5 6 7 8 9 10>这11个数字, 其分别对应的最后一位身份证的号码为<1 0 X 9 8 7 6 5 4 3 2>.
  5. 通过上面得知如果余数是2,就会在身份证的第18位数字上出现罗马数字的Ⅹ。如果余数是10,身份证的最后一位号码就是2.

例如: 某男性的身份证号码是34052419800101001X, 我们要看看这个身份证是不是合法的身份证.

首先: 我们得出, 前17位的乘积和是189.

然后: 用189除以11得出的余数是2.

最后: 通过对应规则就可以知道余数2对应的数字是x. 所以, 这是一个合格的身份证号码.

idcardquery's People

Contributors

mengguoru avatar sincerefly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

idcardquery's Issues

py27跑不动,发个精简版的

str_x = input('input:')
str_x = str(str_x)

tmpsum = int(str_x[0])*7 + int(str_x[1])*9 + int(str_x[2])*10 + int(str_x[3])*5 + int(str_x[4])*8
+ int(str_x[5])*4 + int(str_x[6])*2 + int(str_x[7])*1 + int(str_x[8])*6 + int(str_x[9])*3
+ int(str_x[10])*7 + int(str_x[11])*9 + int(str_x[12])*10 + int(str_x[13])*5
+ int(str_x[14])*8 + int(str_x[15])*4 + int(str_x[16])*2;

remainder = tmpsum % 11

maptable = {0: '1', 1: '0', 2: 'x', 3: '9', 4: '8', 5: '7', 6: '6', 7: '5', 8: '4', 9: '3', 10: '2'}
if maptable[remainder] == str_x[17]:
print(u'<身份证合法>')

else :
print(u'<身份证不合法>')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.