小编Joa*_*ove的帖子

将字符串列表从python/ctypes传递给C函数,期望char**

我有一个C函数,它期望list\0终止的字符串作为输入:

void external_C( int length , const char ** string_list) { 
   // Inspect the content of string_list - but not modify it.
} 
Run Code Online (Sandbox Code Playgroud)

从python(使用ctypes)我想基于python字符串列表调用此函数:

def call_c( string_list ):
    lib.external_C( ?? )

call_c( ["String1" , "String2" , "The last string"])
Run Code Online (Sandbox Code Playgroud)

有关如何在python端构建数据结构的任何提示?注意我保证C函数不会改变string_list中字符串的内容.

问候

乔金 -

c python ctypes

20
推荐指数
3
解决办法
8580
查看次数

标签 统计

c ×1

ctypes ×1

python ×1