我是Python的新手,我正在尝试使用ctypes使用.dll库
出现错误“ winerror 193 1不是有效的win32应用程序”
这是我用来创建.dll的C代码
__declspec(dllexport) int sum(int a, int b) {
return a + b;
}
这是我尝试导入dll的python代码
from ctypes import cdll
mydll = cdll.LoadLibrary('libTest.dll')
if __name__ == '__main__':
pass
这很简单,但是当我尝试运行它时,我得到了所有这样的错误
Traceback (most recent call last):
File "C:\Users\robertodg\.p2\pool\plugins\org.python.pydev.core_6.4.3.201807050139\pysrc\_pydev_runfiles\pydev_runfiles.py", line 468, in __get_module_from_str
mod = __import__(modname)
File "C:\Users\robertodg\eclipse-workspace\LetsHope\Hope.py", line 8, in <module>
mydll = cdll.LoadLibrary('libTest.dll')
File "C:\Users\robertodg\AppData\Local\Programs\Python\Python37-32\lib\ctypes\__init__.py", line 434, in LoadLibrary
return self._dlltype(name)
File "C:\Users\robertodg\AppData\Local\Programs\Python\Python37-32\lib\ctypes\__init__.py", line 356, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid win32 application
我在带有c和python预期的Windows上使用eclipse,并且正在使用,这是我正在运行的python 在Win32上使用Python 3.7.0(v3.7.0:1bf9cc5093,Jun 27 2018,04:06:47)[MSC v.1914 32位(Intel)]
我知道这很简单,但是现在我已经两天没碰过头了。
预先感谢