Using the Python/C API to get the values of PyStrings in the interpreter as CStrings within a C program
问题 I've been messing around with the Python/C API and have this code: #include <Python.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { //Initialize Python Py_Initialize(); //Run file FILE *fp = fopen("Test.py", "r"); PyRun_SimpleFile(fp,"Test.py"); fclose(fp); //Run Python code PyRun_SimpleString("print(__NAME__)"); PyRun_SimpleString("print(__DESC__)"); PyRun_SimpleString("print(__SKIN__)"); PyRun_SimpleString("onEnable()"); //Finalize Python Py_Finalize(); return