RosettaCodeData/Task/Call-a-function-in-a-shared-library/Python/call-a-function-in-a-shared-library-2.py

8 lines
232 B
Python
Raw Permalink Normal View History

2018-06-22 20:57:24 +00:00
>>> 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