前言:
(tcl 在国内似乎很少有人用,据说因为用的人少,所以中文方面的资料非常少的
python 好像比较好学的,而且用户群比TCL perl 要多,中文资料也蛮多的了,我也在学python)
1. 安装Python2.6.1到C:/python26
2. 用VC2008(VC6.0不行)新建一个VC项目, 在Project Setting中,把C:/python/include加入“其他头文件”那一项,
把c:/python/libs加入link的附加目录里。
一个简单的控制台工程的源代码:
#include "stdafx.h"
#include "Python.h"
int main(int argc, char* argv[])
{
char *psz = NULL;
//初始化python.Python Init
Py_Initialize();
if(!Py_IsInitialized())
{
printf("can't init python.");
return 0;
}
//PyRun_SimpleString("import sys");
//PyRun_SimpleString("sys.path.append('./ ')");
PyObject *pName,*pModule,*pDict,*pFunc,*pArgs, *pRes;
//这个就是你要嵌入的python文件名.
pName = PyString_FromString("pytest"