PyObject* IMUL(PyObject* self, PyObject* args)
{
int n, result;
if (!PyArg_ParseTuple(args, "i:arg1", &n))
return NULL;
result = n*2;
return Py_BuildValue("i", result);
}
static PyMethodDef exampleMethods[] =
{
{ "IMUL", IMUL, METH_VARARGS, "doc" },
{ NULL, NULL }
};
void initModule()
{
PyObject* m;
m = Py_InitModule("example", exampleMethods);
}
int main(int argc,char*argv[])
{
Py_SetProgramName(argv[0]);
Py_SetPythonHome("./");
Py_Initialize();
initModule();
Py_Finalize();
system("pause");
return 0;
}
from PIL import Image
import example
def great_function(a):
return a*2
print example.IMUL(4)
print("Run...")
im = Image.open('test.bmp')
im.show()