[英]Too many arguments in my function - Python
我試圖在一個DLL中訪問我的函數並將值作為整數傳遞給它。 但我得到一個ValueError:
Procedure probably called with too many arguments (4 bytes in excess)
我的python .py腳本如下:
func2.restype = c_int
func2.argtypes = [c_int]
func2(3)
...
我在dll中的實際功能只是一個簡單的功能,如:
int DLLfun2(int argtest) { return argtest + 1; };
...
看起來像一個簡單的問題,但我猜我錯過了一些東西。 請幫助。
干杯。
看起來很奇怪,因為整數應該自動轉換,但嘗試使用func2(c_int(3))
編輯:根據ctypes文檔 ,由於錯誤的調用約定(cdecl而不是stdcall),可能會引發此異常。 但仍然調用該函數(只是一種警告:s)
請務必在你的dll中聲明。
如果使用windll
加載庫,則必須使用stdcall調用約定,否則使用cdll
模塊。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.