Git Product home page Git Product logo

idinfo's Introduction

一个简单的提取 🇨🇳 身份证号码内含信息的工具

根据身份证号码提取该号码所在省(直辖市)、市、县(区)、生日、年龄以及进行合法性校验。

🔥 省、市、区信息来自民政部官网发布数据,优先匹配能匹配成功的最新数据。举两个例子:

🌰 330481 原为海宁县,现已变更为海宁市,行政区划代码未调整。则查询 330481 的结果为海宁市。

🌰 330107 原为半山区,现该区已并入拱墅区,行政区划代码已撤销。则查询 330107 的结果为半山区。

🍜 使用方法

from  idInfo import idInfo
idInfo(idNumber,basePath)
@params idNumber str: 省份证号码
@params basePath可选str: 地区代码文件共有地址
        默认为'idinfo/regionalismCode/regionalismCode_'

🙅 不要改动行政区划代码信息文件名中的数字。需要将此数字作为文件名结尾 ( 如 regionlismCode_2019 中的 2019),

😄 获取区域信息

👉 获取省(直辖市、特别行政区)名称

.getProvince()

返回对应省的中文名称 str。未匹配成功返回 unmatched

eg:

idInfo('35################').getProvince()
# 福建省

👉 获取市名称

.getCity()

返回对应市的中文名称 str。未匹配成功返回 unmatched

eg:

idInfo('3501##############').getProvince()
# 福州市

👉 获取区(县)名称

.getCounty()

返回对应市的中文名称 str。未匹配成功返回 unmatched

eg:

idInfo('350104############').getCounty()
# 仓山区

😄 获取年龄信息

.getAge()

返回对应身份证号码匹配的年龄 int

eg:

idInfo('35010419860321####').getCounty()
# 35

😄 获取性别信息

.getSex()

返回对应身份证号码匹配的性别 str

eg:

idInfo('350104198603210047').getSex()
# 女

😄 获取生日信息

.getBirthDay()

返回对应身份证号码匹配的生日 str

eg:

idInfo('350104198603210047').getSex()
# 19860321

😄 合法性检验

.isLegal()

检查对应身份证号码是否合法 int,返回 0 代表不合法,1 代表合法

eg:

idInfo('350104198603210047').isLegal()
# 0

📄 TODO

  • 异常处理

idinfo's People

Contributors

omvira avatar wnewey avatar

Watchers

 avatar

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.