Skip to main content

Extract Chinese identity card info (gender, birthday and regions)

Project description

cid

https://img.shields.io/pypi/v/cid.svg https://img.shields.io/pypi/dm/cid.svg

Chinese Identity Parser

提取身份证号码中的生日、性别、办证区域, 校验身份证号码格式是否正确

Install

pip install cid

Usage

In [1]: from cid import IdParser

In [2]: ip = IdParser()

In [3]: ip.parse('360730198601011111')
Out[3]:
{'birthday': '1986-01-01',
 'gender': '男',
 'region': {'city': '赣州市', 'district': '宁都县', 'province': '江西省'}}

# 校验身份证号码格式是否正确

In [4]: ip.is_valid_cid('360730198601011111')
Out[4]: False


In [5]: ip.extract_gender('360730198601011111')
Out[5]: '男'

In [6]: ip.extract_birthday('360730198601011111')
Out[6]: '1986-01-01'

In [7]: ip.extract_region('360730198601011111')
Out[7]: {'city': '赣州市', 'district': '宁都县', 'province': '江西省'}

# 除了提取发证地,需要实例化 IdParser 外, 其他方法可直接使用

In [8]: from cid import (is_valid_cid, extract_gender, extract_birthday)

Changelog

0.1.1 - Apr 5, 2016

  • update data.csv

0.1 - Apr 1, 2016

  • first version

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

cid-0.1.2.tar.gz (46.1 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: cid-0.1.2.tar.gz
  • Upload date:
  • Size: 46.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for cid-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b276f383720d076001293fd12a7d503aacbc8a9ee8c26a4bb771ff7ffa07c2ec
MD5 486488ae9b9dee7c270f1aca86bfaa53
BLAKE2b-256 b3c8879549a701f480bca4647eab9b58726b534d5289ed2f7a9a15357f1ef37e

See more details on using hashes here.

Supported by

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