RosettaCodeData/Task/Call-a-function-in-a-shared-library/Python/call-a-function-in-a-shared-library-2.py
2018-06-22 20:57:24 +00:00

7 lines
232 B
Python

>>> import ctypes
>>> # libc = ctypes.cdll.msvcrt # Windows
>>> # libc = ctypes.CDLL('libc.dylib') # Mac
>>> libc = ctypes.CDLL('libc.so') # Linux and most other *nix
>>> libc.printf(b'hi there, %s\n', b'world')
hi there, world.
17