3
我该如何运行python数据,我用Python.h在内存中加载了?我正在使用包含已编译的Python代码的专有文件格式。从内存中运行pyc数据C
例如,我的代码
FILE *fp;
long code_size;
char *code;
fp = fopen("file.format", "rb");
fread(&code_size, sizeof(long), 1, fp);
if (code_size > 0)
{
code = malloc(code_size);
/* the pyc data starts at offset 0x100 for example */
fseek(fp, 0x100, SEEK_SET);
/* read the pyc into the allocated memory */
fread(code, sizeof(char), code_size, fp);
/* execute the pyc data somehow using functions in Python.h.. */
}
fclose(fp);
[documentation](http://docs.python.org/extending/index.html)位于python站点上。 – 2012-01-19 00:29:37