意大利财政代码的python库(codicefiscale)
codicefiscale的Python项目详细描述
意大利财政代码的python库
CodiceFiscale是一个用于处理意大利财政代码的Python库 官方称为意大利的科迪丝·菲斯卡尔。
版权所有(c)2009-2016 Emanuele Rocca
主页:https://github.com/ema/pycodicefiscale
这个库是免费软件;您可以重新分发它和/或 根据GNU小公众条款修改 自由软件基金会发布的许可证;或者 许可证的2.1版,或(由您选择)任何更高版本。
这个图书馆的发行是希望它能有用, 但没有任何保证;甚至没有 适销性或适合某一特定目的的适销性。看GNU 更详细的信息,请参阅较低的通用公共许可证。
你应该收到一份GNU的副本 与此库一起使用许可证;如果没有,请写入免费软件 美国马萨诸塞州波士顿市富兰克林街51号基金会,邮编:02110-1301
CodiceFiscale模块文档
一个简单的例子
>>> import datetime >>> from codicefiscale import build >>> >>> build('Rocca', 'Emanuele', datetime.datetime(1983, 11, 18), 'M', 'D969') 'RCCMNL83S18D969H'
模块内容
build(surname, name, birthday, sex, municipality) -> string
Computes the fiscal code for the given person data.
- eg: build(‘Rocca’, ‘Emanuele’, datetime.datetime(1983, 11, 18), ‘M’, ‘D969’)
- -> RCCMNL83S18D969H
control_code(input_string) -> int
Computes the control code for the given input_string string. The expected input_string is the first 15 characters of a fiscal code.
eg: control_code(‘RCCMNL83S18D969’) -> ‘H’
get_birthday(code) -> string
Birthday of the person whose fiscal code is ‘code’, in the format DD-MM-YY.
Unfortunately it’s not possible to guess the four digit birth year, given that the Italian fiscal code uses only the last two digits (1983 -> 83). Therefore, this function returns a string and not a datetime object.
eg: birthday(‘RCCMNL83S18D969H’) -> 18-11-83
get_sex(code) -> string
The sex of the person whose fiscal code is ‘code’.
- eg: sex(‘RCCMNL83S18D969H’) -> ‘M’
- sex(‘CNTCHR83T41D969D’) -> ‘F’
isvalid(code) -> bool
This function checks if the given fiscal code is syntactically valid.
- eg: isvalid(‘RCCMNL83S18D969H’) -> True
- isvalid(‘RCCMNL83S18D969’) -> False