Let's call a simple C code from Python with ctypes.
test.c
#include <stdio.h>
void hello_world(void)
{
printf("Hello, world!\n");
}
Compile this with the following command to make it a shared file.
gcc test.c -shared -fPIC -o libtest.so
ctypes_test.py
import ctypes
libc = ctypes.cdll.LoadLibrary('./libtest.so')
libc.hello_world()
You can run it with the following command
python3 ctypes_test.py
Execution result
Hello, world!