須要注意的是,方法調用的時候須要嚴格的對應,若是是使用_stdcall
修飾的方法,那麼就只能用對應的類型的工具加載,若是不使用,極可能會出現找不到的現象。python
對於動態連接庫的調試,官方文檔給出瞭解決方案,使用faulthandler
模塊來調試。工具
如何進行嚴格的傳入類型聲明。調試
restype argtypes
,前者聲明返回類型,後者聲明傳入類型。案例一rest
#include<stdio.h> extern "C" int test(int n) { printf("hello test%d\n",n); return n; }
from ctypes import * handle = cdll.LoadLibrary("./test.dll") handle.test.restype = c_int handle.test.argtypes = [c_int] n = handle.test(22) print(n,type(n))