RosettaCodeData/Task/Call-a-function-in-a-shared-library/Python/call-a-function-in-a-shared-library-2.py
2023-07-01 13:44:08 -04: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