python ctypes库2_指定参数类型和返回类型详解
作者:inch2006 发布时间:2021-10-17 14:34:50
标签:python,ctypes库2,参数,返回
python函数的参数类型和返回类型默认为int。
如果需要传递一个float值给dll,那么需要指定参数的类型。
如果需要返回一个flaot值到python中,那么需要指定返回数据的类型。
数据类型参考python文档:
https://docs.python.org/3.6/library/ctypes.html#fundamental-data-types
import ctypes
path = r'E:\01_Lab\VisualStudioLab\cpp_dll\cpp_dll\Debug\cpp_dll.dll'
dll = ctypes.WinDLL(path)
dll.add_float.argtypes = [ctypes.c_float,ctypes.c_float]
dll.add_float.restype = ctypes.c_float
data_float = dll.add_float(7,10) # (ctypes.c_float(7.0),ctypes.c_float(10.0))
c++中函数如下:
DLLEXPORT float __stdcall add_float(float a,float b)
{
float sum = a + b;
return sum;
}
来源:https://blog.csdn.net/inch2006/article/details/79908384
0
投稿
猜你喜欢
- 今天看书讲T-SQL,看到了UNBOUNDED PRECEDING,就想比对下ROW_NUMBER()的运行速度。sql及相关的结果如下,数
- SNMP标准引入一组ASN.1语言元素,称之为SMI(Structure of Management Information)。由SMI描述
- jQuery.post( url, [data], [callback], [type]
- 在SQL Server 2008里安装审计,步骤如下:1. 给每个SQL Server 2008具体实例创建一个SQL Server审计2.
- 1.介绍PDF 格式是与平台无关,它独立于底层操作系统和渲染引擎。事实上,PDF 是基于一种脚本语言—&mdas
- 春节来到,红包们大概率在微信各大群中肆虐,大家是否都一样不抢到红包们心里就感觉错过了一个亿,可总会被这事那事耽误而遗憾错过,下面用 Pyth
- 加载mnistimport numpydef loadMnist() -> (numpy.ndarray,numpy.ndarray,
- string.Template()string.Template()内添加替换的字符, 使用"$"符号, 或 在字符串内
- 查找出SQLServer的死锁和阻塞的源头 --查找出SQLServer死锁和阻塞的源头use mastergodeclare @spid
- 如果你的Pycharm提示过期可以使用下面这个最新的Pycharm激活码,适用最新版的Pycharm 2020.2.3,老版本的Pychar
- 网页上搜索 “python绘制国际象棋棋盘”,索引结果均为调用 turtle 库绘制棋盘结果;为了填充使用 python PIL 图像处理库
- 如下所示:# 计算0到100之间的之间所有的数字累计求和结果# 定义最终结果的变量result = 0# 定义一个整数的变量来记录循环次数i
- JavaScript的对象都是实例化了的,只可以使用而不能够创建继承于这些对象的新的子类. window对象为所有对象的Parent win
- 在了解了JavaScript1.7的相关更新后,我们再继续关注JavaScript1.8的新特性。在W3C Group带来的JavaScri
- python代码实现冒泡排序代码其实很简单,具体代码如下所示:代码Code highlighting produced by Actipro
- 用js实现漂亮的雪花飘过效果:步骤:页面基本样式,雪花旋转动画效果body{ width: 100vw; height: 100vh; ba
- 目录1.jupyter2.jupyter基础操作2.1windows更新pip库2.2jupyter安装2.3初次启动jupyter2.4设
- 一、使用ddt和data装饰器的大致框架如下,每个test_开头的方法,代表一条测试用例from ddt import ddt,dataim
- 什么是接口测试接口测试主要用于检测外部系统与内部系统之间,以及系统内部各 个子系统之间的交互点。其测试的重点是,检查数据的交换、传递和控 制
- 前言在使用 Go 语言开发过程中,我们不免会定义结构体,但是我们定义的结构体都是有字段的,基本不会定义不包含字段的 空结构体。你可能会反过来