通过身份证号码提取年龄,性别
通过 提取 年龄 身份证 号码 性别
2023-09-14 08:57:25 时间
class GetInformation(object): def __init__(self,id): self.id = id self.birth_year = int(self.id[6:10]) self.birth_month = int(self.id[10:12]) self.birth_day = int(self.id[12:14]) def get_birthday(self): """通过身份证号获取出生日期""" birthday = "{0}-{1}-{2}".format(self.birth_year, self.birth_month, self.birth_day) return birthday def get_sex(self): """男生:1 女生:2""" num = int(self.id[16:17]) if num % 2 == 0: return 2 else: return 1 def get_age(self): """通过身份证号获取年龄""" now = (datetime.datetime.now() + datetime.timedelta(days=1)) year = now.year month = now.month day = now.day if year == self.birth_year: return 0 else: if self.birth_month > month or (self.birth_month == month and self.birth_day > day): return year - self.birth_year - 1 else: return year - self.birth_year
相关文章
- 通过网页或者移动设备链接跳转qq(tim)添加好友(群)
- ASP.NET防止自己网站的资源被盗(通过IHttpHandler 带样例说明)
- 通过Kubernetes监控探索应用架构,发现预期外的流量
- python通过socket实现多个连接并实现ssh功能详解
- 通过类的多态性确定人类的说话行为
- 通过keytool生成证书,并提取公钥和私钥
- Atitit 数据挖掘之道 attilax总结 艾龙著 1. 数据挖掘一般是指从大量的数据中通过算法搜索隐藏于其中信息的过程。1 2. 数据(Data)-信息(information)-知识(K
- m通过目标形心提取、颜色模型以及边缘提取实现两个相向移动人员交叉遮挡过程的检测和分割matlab仿真
- m通过手动提取图像特征点实现医学图像配准和拼接matlab仿真
- Python编程:通过百度文字识别提取表格数据
- QT 通过QNetworkReply *获取对应请求的URL地址
- 通过Python的PIL库进行图像的过滤
- Java 读取shp文件,生成shp文件,通过shp文件自动建库