私信  •  关注

Palec Jadav Bheda

Palec Jadav Bheda 最近创建的主题
Palec Jadav Bheda 最近回复了
8 年前
回复了 Palec Jadav Bheda 创建的主题 » 如何在Python中使用C库?

问题是,如果我理解正确,如何从Python调用C函数。那么,最好的选择是Ctypes(顺便说一句,在所有Python变体中都是可移植的)。

>>> from ctypes import *
>>> libc = cdll.msvcrt
>>> print libc.time(None)
1438069008
>>> printf = libc.printf
>>> printf("Hello, %s\n", "World!")
Hello, World!
14
>>> printf("%d bottles of beer\n", 42)
42 bottles of beer
19

有关详细指南,请参阅 my blog article .