python 带点的 ctype

python ctypes with dots

如何使用名称中带点的 ctypes 加载模块 示例

mydll.1.0.dll

尝试像这样加载它

ctypes.cdll.mydll.1.0

给出模块未找到错误

我在 windows

上使用 python

来自评论的回答:

Use ctypes.CDLL('mydll.1.0').

If you're fixed on using the loader it's ctypes.cdll['mydll.1.0']. Just note that the loader caches the CDLL instance, which caches functions. That can be good or bad depending your use case and whether other packages want to use the same DLL but don't define function prototypes (i.e. restype, argtypes, errcheck, paramflags) equivalently.