Python±Ê¼Ç£¨Ò»£©——C/C++µ÷ÓÃpython
×î½üÒòΪÑо¿Ò»¸ö¶«Î÷£¬²¢ÇÒÔںܾÃÒÔǰ¾ÍÏë°ÑpythonºÃºÃ¿´¿´¡£ÕýºÃÂú×ãÎ񵀼̮æÐÄ¡£ÎÒÿÌìÉϰà×öµÃÓÎÏ·¶¼ÊÇÓÃlua£¬Ò²ÊÇÒ»ÃźÜÇ¿´óµÄ½Å±¾ÓïÑÔ¡£¿ÉÄÜÎÒ¸üϲ»¶pythonµÄËõ½øÇø·ÖºÍÃæÏò¶ÔÏó°É¡£ ½ñÌìֻдһ¸ö¼òµ¥µÄÀý×Ó¡£Ò»¸ö¼òµ¥µÄpython½Å±¾£¬¾ÍÒ»¸öº¯Êý£¬ÓÃC/C++È¥µ÷Ó᣿ÉÄÜÕâÒ²ÊÇ×÷Ϊ³ÌÐòÀ´Ëµ×î¹ØÐĵÄÒ»¼þÊ¡£ËùÒÔÎÒµÄpython±Ê¼ÇÒ²¾Í×îÏÈдÕâ¿é¡£- - ºÃÇÐÈëÕýÌ⣺
#include <Python.h>
#include <stdio.h>
void test( void )
{
PyObject *pMod = NULL;
PyObject *pFun = NULL;
PyObject *pParm = NULL;
PyObject *pRetVal = NULL;
int iRetval = 0;
if ( pMod = PyImport_ImportModule( "add" ) )
{
if ( pFun = PyObject_GetAttrString( pMod, "add" ) )
{
pParm = PyTuple_New( 2 );
PyTuple_SetItem( pParm, 0, Py_BuildValue( "i", 300 ) );
PyTuple_SetItem( pParm, 1, Py_BuildValue( "i", 500 ) );
pRetVal = PyEval_CallObject( pFun, pParm );
PyArg_Parse( pRetVal, "i", &iRetval );
printf( "result: %d\n", iRetval );
}
else
printf( "Not found fun!\n" );
}
else
printf( "Not found module!\n" );
}
int main( void )
{
Py_Initialize();
&n
Ïà¹ØÎĵµ£º
PythonÖеÄÎļþ²Ù×÷ÒÔ¼°ÊäÈëÊä³ö
ÎÒÃÇ¿ÉÒÔ·Ö±ðʹÓÃraw_inputºÍprintÓï¾äÀ´Íê³ÉÕâЩ¹¦ÄÜ¡£¶ÔÓÚÊä³ö£¬ÄãÒ²¿ÉÒÔʹÓöàÖÖ¶àÑùµÄstr£¨×Ö·û´®£©Àà¡£ÀýÈ磬ÄãÄܹ»Ê¹ÓÃrjust·½·¨À´µÃµ½Ò»¸ö°´Ò»¶¨¿í¶ÈÓÒ¶ÔÆëµÄ×Ö·û´®¡£ÀûÓÃhelp(str)»ñµÃ¸ü¶àÏêÇé¡£
ÁíÒ»¸ö³£ÓõÄÊäÈë/Êä³öÀàÐÍÊÇ´¦ÀíÎļþ¡£´´½¨¡¢¶ÁºÍдÎļþµÄÄÜÁ¦ÊÇ ......
/¼ÓÁËÏÂÃæÁ½¸öÍ·Îļþ£¬ÊÇΪÁËÔÚWin32¹¤³ÌÖÐʹÓÃMFCµÄÌØÐÔ!
#include <afx.h>
#include <afxwin.h>
#include "stdio.h"
#include "conio.h"
////¼ÓÁËÏÂÃæÁ½¾ä£¬ÊÇΪÁËÄܹ»ÓÃstring(basic_stringÀàÐÍ)
#include <string>
using namespace std;
int main(int argc, char* argv[ ......
½ñÌìÈ¥ÃæÊÔÒ»¼Ò¹«Ë¾£¬ÌîÁËÒ»·Ý“»§¿Úµ÷²é”£¬È»ºó¾ÍÊÇ×öÒ»·ÝÃæÊÔÌ⣬ÌâÄ¿ºÜ¼òµ¥
1¡¢¸Ä´íÌ⣬¸øÒ»¶Î³ÌÐò£¬Ö¸³ö´íÎó
2¡¢Socket×èÈûºÍ·Ç×èÈû±à³Ì£¬·Ç×èÈûµÄʵÏÖÔÀí
3¡¢TCP/IPÓëOSIÆß²ãÄ£ÐÍ
TCP/IP²Î¿¼Ä£Ð͹²ÓÐÎå²ã£ºÓ¦Óò㡢´«Êä²ã¡¢»¥ÁªÍø²ãºÍÖ÷»úÖÁÍøÂç²ã¡£
ÓëOSI²Î¿¼Ä£ÐÍÏà±È£¬TCP/IP²Î¿¼Ä£ÐÍûÓбíʾ²ãºÍ» ......
±àÕß°´:·Ç³£»ù±¾¹ØÓÚCÓïÑÔµÄÎÊÌâ,Ò»¸öÐÅÏ¢Àà(¼ÆËã»ú,×ÊѶ¹¤³Ì,µç×Ó¹¤³Ì, ͨÐÅ
¹¤³Ì)רҵµÄ±¾¿Æ±ÏÒµÉúÓ¦¸Ã´ïµ½µÄˮƽ¡£ÌâÄ¿²»ÄÑ,È«²¿¶¼ÄÜ¿ìËٵشðÍ꣬µ±È»Ò²ÐèÒª
Ò»¶¨µÄ֪ʶ´¢±¸¡£
¶ÔÓÚ´ó¶àÊýÈË£¬ÎÒÃÇÔ¤ÆÚÄã¿ÉÄÜ´ð´í 1) 4) 15)Ì⣬ËùÒÔ´ð´í3µÀÒÔÄڵģ¬ÎÒÃÇÈÏΪ
ÄãºÜ°ô
´ð´í5µÀÌâÒÔ ......
ÕÅТÏé
ÁíÍ⣬ÔÚʵ¼ÊµÄVC++½ÌѧÖУ¬·¢ÏÖºÜÉÙÓÐÕæÕý¾«Í¨ÁËCÓïÑÔ±à³ÌµÄѧԱ£¬Ò»°ã¶¼Óлò¶à»òÉÙ¸ÅÄî²»ÊÇÍêÈ«Çå³þµÄÎÊÌâ£¬ÌØ±ðÊÇһЩÐèÒª·á¸»µÄʵս¾Ñé²ÅÄÜÌå»áºÍÃ÷°×µÄÎÊÌ⣬Èç×Ö·û´®£¬Ö¸Õ룬ÀàÐÍת»»£¬¶¨ÒåÖ¸Ïòº¯ÊýµÄÖ¸ÕëÀàÐÍ£¬ÕâÒ²Êǵ¼ÖÂѧϰVC++À§ÄѵÄÒ»¸öÔÒò¡£ÏÂÃæÓÐ ......