Skip to main content

一个可以离线检验公民身份号码是否合法的程序

Project description

pymod112

一个基于Python开发的公民身份号码检验与地区代码查找程序

by HoshsL

安装

PyPI

使用pip安装,仅支持Python 3.10及以上版本

pip install pymod112

使用

校验身份证号码(隐藏详情)

>>> import pymod112
>>> pymod112.mod112('11010519491231002X')
True

校验身份证号码(显示详情)

>>> import pymod112
>>> pymod112.mod112('11010519491231002X', details=True)
{'id': '11010519491231002X',
 'province': ['11', '北京市'],
 'city': ['01', ''],
 'county': ['05', '朝阳区'],
 'birth_date': ['1949', '12', '31'],
 'gender': '女',
 'result': True,
 'problem': '000'}

查询地区代码对应的地区名

>>> import pymod112
>>> pymod112.code2location('110105')
['北京市', '', '朝阳区']

查询地区名对应的地区代码

>>> import pymod112
>>> pymod112.location2code(['北京市', '朝阳区'])
'110105'

返回全部错误代码及其对应内容

>>> import pymod112
>>> pymod112.CODE2ERROR
{'000':'不存在问题',
 '002':'参数location长度错误',
 '003':'参数code长度错误',
 '004':'参数id长度错误',
 '005':'参数id内容包含非法字符',
 '006':'参数id不合法',
 '007':'参数id中包含不存在的地区',
 '008':'参数id中包含不存在的时间'}

许可证

MIT License

更新日志

0.1.2(2023-8-5)

  • 错误修复
    • 修复了参数id来自同年的未来时间也可能通过时间校验的问题
    • 修复了参数id最后一位不合法但不会返回错误代码005的问题
  • 新增
    • 新增函数location2code以方便查询行政区划代码
  • 改进
    • 修改了一个函数名(code_to_location -> code2location)
    • 修改了一个常量名(code_to_error -> CODE2ERROR)
    • 函数code2location参数code要求类型由list变为code
    • 更新了CODE2ERROR
    • 函数mod112返回中'gender'的值变为'男'或'女'
  • 其它
    • 开源许可证更改为MIT License

0.1.1(2023-7-2)

  • 加入参数类型检查
  • 优化错误代码(停用001 002 003)
  • 删除函数problem()

0.1.0(2023-6-24)

  • 这是第一个正式发行版

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymod112-0.1.2.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

pymod112-0.1.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file pymod112-0.1.2.tar.gz.

File metadata

  • Download URL: pymod112-0.1.2.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for pymod112-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d2c75c2b6594f72ef3ee8f476c560b3053e88d1d1f0cba997aca116d136fea7f
MD5 b82909aaf632591445b336804c0a1f3f
BLAKE2b-256 eea66230102bdc31c65157382906809fa1b14bd48fedd6d882d1c01a49784b12

See more details on using hashes here.

File details

Details for the file pymod112-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pymod112-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for pymod112-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a9635c1cb6eaf761a87903cf18a7721352596f84267242b86e9985568296e9ec
MD5 de81fe304aab25d817fde6db4a7f8a2f
BLAKE2b-256 5818287d8c8b233c9cac666a5c1373c8f8bd375706d1a16d9efc95b98919315c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page