一个可以离线检验公民身份号码是否合法的程序
Project description
pymod112
一个基于Python开发的公民身份号码检验与地区代码查找程序
by HoshsL
安装
使用pip安装,仅支持Python 3.10及以上版本
pip install pymod112
使用
校验身份证号码(隐藏详情)
>>> import pymod112
>>> pymod112.mod112('11010519491231002X')
True
校验身份证号码(显示详情)
>>> import pymod112
>>> pymod112.mod112('11010519491231002X', details=True, location_check=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':'不存在问题',
'001':'缺失关键文件',
'002':'参数location长度错误',
'003':'参数code长度错误',
'004':'参数id长度错误',
'005':'参数id内容包含非法字符',
'006':'参数id不合法',
'007':'参数id中包含不存在的地区',
'008':'参数id中包含不存在的时间'}
返回区划码版本
>>> import pymod112
>>> pymod112.RCLIST
["24", "20"]
许可证
MIT License
更新日志
0.1.5(2025-11-7)
- 错误修复
- 更新了区划码,修复了地址检查出错的可能性
- 新增
- 新增可选参数rc_time,默认最新版,可选版本请查找RCLIST
- 新增常量RCLIST,存储区划码版本,最新版本是RCLIST[0]
0.1.4(2024-9-21)
- 错误修复
- 修复了资源缺失的问题
- 新增
- 新增最早出生时间检查
- 新增错误代码'001'
- 新增对关键资源的检查
- 已知问题
- 存在地址检查出错的可能性
0.1.2(2023-8-5)
- 错误修复
- 修复了参数id来自同年的未来时间也可能通过时间校验的问题
- 修复了参数id最后一位不合法但不会返回错误代码005的问题
- 新增
- 新增函数location2code以方便查询行政区划代码
- 改进
- 修改了一个函数名(code_to_location -> code2location)
- 修改了一个常量名(code_to_error -> CODE2ERROR)
- 函数code2location参数code要求类型由list变为str
- 更新了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.5.tar.gz
(58.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
pymod112-0.1.5-py3-none-any.whl
(57.2 kB
view details)
File details
Details for the file pymod112-0.1.5.tar.gz.
File metadata
- Download URL: pymod112-0.1.5.tar.gz
- Upload date:
- Size: 58.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dfc521d16c1ab5cc38d1a4c5aca609723c5ba098ad2a7210079947b63886d7b4
|
|
| MD5 |
79025ed1ea33c914539d95894d4b8320
|
|
| BLAKE2b-256 |
4d0b8625fd877410c3c46bb9a7d1a39cb15fe9376b0a88f03b02ccd9b76c681d
|
File details
Details for the file pymod112-0.1.5-py3-none-any.whl.
File metadata
- Download URL: pymod112-0.1.5-py3-none-any.whl
- Upload date:
- Size: 57.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50a173360f99fa9e5781d2d98ce06baf0d218daec2ac5ab78987d10ece52e052
|
|
| MD5 |
cc40291565b538096f250ef8e6695354
|
|
| BLAKE2b-256 |
0ce70fbdb4b4f32032e983cae575ce236ec2a60ac8700bbda5542415c0fc728a
|