亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

python ctypes庫2_指定參數(shù)類型和返回類型詳解

 更新時(shí)間:2019年11月19日 10:03:55   作者:inch2006  
今天小編就為大家分享一篇python ctypes庫2_指定參數(shù)類型和返回類型詳解,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧

python函數(shù)的參數(shù)類型和返回類型默認(rèn)為int。

如果需要傳遞一個(gè)float值給dll,那么需要指定參數(shù)的類型。

如果需要返回一個(gè)flaot值到python中,那么需要指定返回?cái)?shù)據(jù)的類型。

數(shù)據(jù)類型參考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++中函數(shù)如下:

DLLEXPORT float __stdcall add_float(float a,float b)
{
 float sum = a + b;
 return sum;
}

以上這篇python ctypes庫2_指定參數(shù)類型和返回類型詳解就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論