python 调用so动态库函数时传char参数
import ctypes
from ctypes import *
ll = cdll.LoadLibrary
h_so = '/usr/lib/test.so'
lib = ll(h_so)
hid = ''.encode('utf-8')
lib.testfun.argtypes = [ctypes.c_char_p]
res = lib.testfun(hid)
printf = lib.printf
printf(hid)
so_hwid = c_char_p(hid).value.decode()
这套代码也能运行
lib = CDLL('/usr/lib/test.so')
p = create_string_buffer(1024)
res = lib.uoshwinfo_deviceh_get_hwid(p)
printf = lib.printf
printf(p)