项目需要python调用.so文件,使用网上的教程会抛出异常。而这种方法可以完整调用,但是我忘记当初是怎么写的了。。。如果后面还要用到再来完善。

from ctypes import *

adddll=cdll.LoadLibrary("./libpyckapi.so")
adddll.sendRequestAuthorizationPython.argtypes = [c_char_p]
adddll.sendRequestAuthorizationPython.restype = c_char_p
addres = adddll.sendRequestAuthorizationPython(b'')
print(addres.decode("utf8"))

adddll.getAuthorizationResultPython.argtypes = [c_char_p]
adddll.getAuthorizationResultPython.restype = c_char_p
addres = adddll.getAuthorizationResultPython(addres)
print(addres.decode("utf8"))