我遇到了ctypes的问题.我认为我的类型转换是正确的,错误对我没有意义."arg - ct.c_char_p(logfilepath)"行错误TypeError:预期的字节或整数地址而不是str实例
我试过python 3.5和3.4.
功能我打电话:
stream_initialize('stream_log.txt')
Run Code Online (Sandbox Code Playgroud)
Stream_initialize代码"
def stream_initialize(logfilepath):
f = shim.stream_initialize
arg = ct.c_char_p(logfilepath)
result = f(arg)
if result:
print(find_shim_error(result))
Run Code Online (Sandbox Code Playgroud)
use*_*367 19
c_char_p接受bytes对象,所以你必须转换string为bytes第一个:
ct.c_char_p(logfilepath.encode('utf-8'))
Run Code Online (Sandbox Code Playgroud)
另一种解决方案是使用c_wchar_p带有a 的类型string.
| 归档时间: |
|
| 查看次数: |
9965 次 |
| 最近记录: |