基本信息
源码名称:精伦 python 二开源码
源码大小:0.32M
文件格式:.zip
开发语言:Python
更新时间:2024-05-15
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
# -*- coding : utf-8-*-
# 本Python读取身份证信息的支持的型号有:iDR210-HID系列身份证社保卡读卡器
import ctypes
# 调用动态链接库函数的功能模块ctypes,提供和c兼容的数据类型,允许调用动态库中的函数
from ctypes import *
import os
dll_path = f'{os.getcwd()}' '/Sdtapi.dll'
class IdrRead(object):
def __init__(self):
self.id_dev = CDLL(dll_path)
self.id_handle = self.id_dev.InitComm(1001)
def get_id_msg(self): # 读身份证
self.id_dev.Routon_RepeatRead(True)
if self.id_handle != 1:
return -1 # 打开设备失败
if self.id_dev.Authenticate() != 1: # 认证卡片
return 0 # 读取身份证失败
# 定义id信息
msg = ctypes.create_string_buffer(192)
if self.id_dev.ReadBaseMsg(msg, 0) == 1:
self.id_dev.HID_BeepLED(True, True, 100)
id_msg_str = {'name': msg.raw[0:31].replace(b'\x00', b'').decode('gbk'),
'sex': msg.raw[31:34].replace(b'\x00', b'').decode('gbk'),
'people': msg.raw[34:44].replace(b'\x00', b'').decode('gbk'),
'birthday': msg.raw[44:53].replace(b'\x00', b'').decode('gbk'),
'address': msg.raw[53:124].replace(b'\x00', b'').decode('gbk'),
'number': msg.raw[124:143].replace(b'\x00', b'').decode('gbk'),
'agency': msg.raw[143:174].replace(b'\x00', b'').decode('gbk'),
}
return id_msg_str
else:
return 0 # 读取身份证失败
def get_bank_msg(self):
if self.id_handle != 1:
return -1 # 打开设备失败
else:
return 2 # 设备不支持
# id_dev.CloseComm() # 关闭连接
if __name__ == "__main__":
id_msg = IdrRead()
# 读身份证
id_card_msg = id_msg.get_id_msg()
print(id_card_msg)
【源码目录】
routon
├── Dewlt.dll
├── Sdtapi.dll
└── main.py
0 directories, 3 files