开发者

Python and C coupling

I tried loading C shared library .so in Python using ctypes.CDLL class (Linux). Here is the link to which tells what I did. As I see the documentation it says CDLL class assumes that function returns int types. I've a doubt here what if I need to return variable of type开发者_如何学Python other than the int type from a function in C?. And to what extent we can use C functions in Python i mean what are the limits/restrictions on using C shared libraries and functions

Thanks in Advance


By default, it assumes int, but you can set restype to any of the supported types to override that. E.g., from the docs:

strchr.restype = c_char_p

This means that strchr returns a pointer to a char, which corresponds to a Python string (or None, for a NULL pointer).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜