1.去主页下载源代码项目
2.编译下载下来的项目
3.新建项目填入下面代码
// pythonIncludeTest.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <Python.h> #pragma comment(lib, "python33.lib") #pragma warning(disable:4996) int _tmain(int argc, _TCHAR* argv[]) { Py_SetProgramName(argv[0]); Py_SetPythonHome(L"G://SoftProject/cPython/pythonIncludeTest/Debug/"); Py_InitializeEx(0); FILE * fp = NULL; fp = fopen("G://SoftProject/cPython/pythonIncludeTest/Debug/main.py", "r"); if (fp == NULL) { return 1; } PyRun_SimpleFile(fp, "main.py"); //PyRun_SimpleString("import sys\n" // "print(sys.getfilesystemencoding())\n"); Py_Finalize(); scanf("exit"); return 0; }