python-codicefiscale是一个小型库,用于对意大利财政代码进行编码/解码-对财政代码进行编码/解码。
python-codicefiscale的Python项目详细描述
python codicefiscale
python codice fiscale是一个用于编码/解码意大利财政代码的小型库-codicica/decodica del codice fiscale。
功能
- 名称/姓氏的音译
- 多种出生日期格式(datetime/string)(您可以在
tests/tests.py
) - 自动从名称检测出生地城市/外国代码
- omocodia支持
安装
pip install python-codicefiscale
用法
导入
fromcodicefiscaleimportcodicefiscale
编码
codicefiscale.encode(surname='Caccamo',name='Fabio',sex='M',birthdate='03/04/1985',birthplace='Torino')# 'CCCFBA85D03L219P'
解码
codicefiscale.decode('CCCFBA85D03L219P')# {# 'code': 'CCCFBA85D03L219P',# 'sex': 'M',# 'birthdate': datetime.datetime(1985, 4, 3, 0, 0),# 'birthplace': {# 'name': 'TORINO'# 'province': 'TO',# 'code': 'L219',# },# 'omocodes': [# 'CCCFBA85D03L219P',# 'CCCFBA85D03L21VE',# 'CCCFBA85D03L2MVP',# 'CCCFBA85D03LNMVE',# 'CCCFBA85D0PLNMVA',# 'CCCFBA85DLPLNMVL',# 'CCCFBA8RDLPLNMVX',# 'CCCFBAURDLPLNMVU',# ],# 'raw': {# 'code': 'CCCFBA85D03L219P',# 'surname': 'CCC',# 'name': 'FBA',# 'birthdate': '85D03',# 'birthdate_year': '85'# 'birthdate_month': 'D',# 'birthdate_day': '03',# 'birthplace': 'L219',# 'cin': 'P',# },# }
检查
codicefiscale.is_valid('CCCFBA85D03L219P')# True
codicefiscale.is_omocode('CCCFBA85D03L219P')# False
测试
tox
/python setup.py test
/python -m unittest tests.tests
许可证
在MIT License下发布。