Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Python±Ê¼Ç£¨¶þ£©——pythonµ÷ÓÃC/C++Ä£¿é

ǰһƪ½²Á˼òµ¥µÄC/C++µ÷ÓÃPython½Å±¾Ä£¿é£¨.py£©¡£¼ÈÈ»ÊÇÓÃÓÚÖî¶àÓÎÏ·³ÌÐòµÄ½Å±¾ÓïÑÔ£¬Äǿ϶¨ÊÇȱ²»ÁË»¥µ÷£¨ÀñÉÐÍùÀ´£©¡£Òò´Ë£¬±¾Æª½²Ò»¸ö¼òµ¥µÄpythonµ÷ÓÃC/C++дµÄDLLÄ£¿é£¬¶ÔPython½øÐй¦ÄÜÀ©Õ¹¡£ÕâÀïдһ¸ö¼òµ¥µÄÀý×Ó£¬Ö÷Òª¾ÍΪÁËÁ˽âÏÂÕâôÓÃPythonÀ´µ÷ÓÃC/C++дµÄDLL¿â¡£ºÃÁË£¬ÇÐÈëÕýÌ⣺
 Ê×ÏÈ£¬ÎÒÊÇÓÃVS2003½¨µÄÒ»¸öDLL¹¤³Ì£¬½«DLL¹¤³ÌÊôÐÔÀïÃæµÄÊä³öÎļþµÄ(.dll)¸ÄΪ(.pyd)¡£µ±È»Ò²¿ÉÒÔ½«Éú³ÉºóµÄDLLÀ©Õ¹Ãû¸ÄΪ.pyd¡£ºÇºÇ£¡ÃâµÃ´ó¼ÒÒÔΪËüºÜÉñÃØ£¨VC»¹ÄÜÉú³É.pyd¿â£¿ÕâÖÖÒÉÎÊ£¡£©ºÃ£¬Ö±½ÓÌù´úÂë:
#include <Python.h>
int cmd( const char *arg )
{
     int n = system( arg );
     return n;
}
static PyObject * wrap_cmd_fun( PyObject *self, PyObject *args )
{
     const char * command;
     if ( !PyArg_ParseTuple( args, "s", &command ) )
          return NULL;
     int n = cmd( command );
     return Py_BuildValue( "i", n );
}
static PyMethodDef MyCppMethods[] =
{
     { "MyCppFunc", wrap_cmd_fun, METH_VARARGS, "Execute a shell command." },
     { NULL, NULL, 0, NULL }
};
PyMODINIT_FUNC initMyFirstPythonModule( void )
{
     PyObject *m = Py_InitModule( "MyFirstPythonModule", MyCppMethods );
     if (m == NULL)
         return;
}
Õâ¸öʵÀýºÜ¼òµ¥£¬Ê×ÏÈÊÇPy_InitModuleÓÃÓÚ³õʼ»¯ÔÚPython½Å±¾ÖÐÒªimportµÄÄ£¿é£¬ÕâÀïµÄÄ£¿éÃûÊÇ£ºMyFirstPythonModule¡£ÎÒÃÇÔÚPythonÖн«Ê¹ÓÃimport MyFirstPythonModule À´ÔØÈëÕâ¸öÄ£¿é¡£ÕâÀïÎÒÃǽ«MyCppMethods×÷Ϊģ¿éÒªµ÷Óõķ½·¨£¬ËüÊÇÒ»¸öPyMethodDef½á¹¹¡£ÎÒÃÇ¿ÉÒÔ¿´µ½Õâ¸ö½á¹¹µÄÊý×鶨Ò壬{ "MyCppFunc", wrap_cmd_fun, METH_VARARGS, "Execute a shell command." }, ºìÉ«µÄ¾ÍÊÇÎÒÃÇÔڽű¾ÀïÃæÒªµ÷Óõĺ¯ÊýÃû×Ö£¬Ëü±»Ó³ÉäΪwrap_cmd_fun£¬µ±ÔÚPython½Å±¾Öе÷ÓÃMyCppFuncʱ½«»áµ÷ÓÃwrap_cmd_funº¯Êý¡£µÚÈý¸öMETH_VARARGS³ÉÔ±±íʾµ÷Ó÷½Ê½£¬¿ÉÒÔÓûòÔËËãÁ¬½Ó¼¸¸öµ÷Ó÷½Ê½¡£µÚËĸö³ÉÔ±ÊÇÒ»¸ö·½·¨


Ïà¹ØÎĵµ£º

C/VCĿ¼²Ù×÷


C/VCĿ¼²Ù×÷
Ðdz¾ ·¢±íÓÚ 2006-10-11 15:54:00
0
ÍƼö
Ò»¡¢Ä¿Â¼²Ù×÷º¯Êý½éÉÜ
ÔÚVC++µÄ“direct.h”Öж¨ÒåÁËÒÔÏÂ4¸öº¯Êý£º
int chdir(const char *);       //change directory
char * getcwd(char *, int);  //get current working directory
int mkdir(const cha ......

python´¦ÀízipÎļþ£¨×ª£© 2009

 ×ª×Ô http://hi.baidu.com/xunxun129/blog/item/3befad0f8ff992c07bcbe180.html
ÓÐʱÎÒÃÇÐèÒªÔÚ Python
ÖÐʹÓà zip Îļþ£¬¶øÔÚ1.6°æÖУ¬Python ¾ÍÒѾ­ÌṩÁË zipfile Ä£¿é¿ÉÒÔ½øÐÐÕâÑùµÄ²Ù×÷¡£²»¹ý Python ÖеÄ
zipfile Ä£¿é²»ÄÜ´¦Àí¶à¾íµÄÇé¿ö£¬²»¹ýÕâÖÖÇé¿ö²¢²»¶à¼û£¬Òò´ËÔÚͨ³£Çé¿öÏÂÒѾ­×㹻ʹÓÃÁË¡£ÏÂÃæÎÒÖ»Ê ......

µÚÒ»¸öpro*C demo

¸Ã³ÌÐòºÜ¼òµ¥£¬¾ÍÊÇÓÃC´ÓORACLE£¬°Ñµ±Ç°ÈÕÆÚÏÔʾ³öÀ´¾ÍOK£¬×÷Ϊһ¸ö¼òµ¥µÄDEMO
£¨Ò»£©Ð´PRO*C
/*===========================================================================
* pro*c±àÒë·½·¨£º
* Ô¤±àÒë proc test.pc
* ±àÒë   gcc -o test test.c $ORACLE_HOME/lib/libclntsh.so
* ×÷Õß   f ......

[C] ±àÒëµÄѧϰºÍʵ¼ùÈÕÖ¾Îå[¿¼ÊÔ¹éÀ´»°ÕýÔò]

 µ±Ï¶¨¾öÐÄÈ¥×öÒ»¼þÊÂÇéµÄʱºò,¾ÍûÓÐʲô¿ÉÒÔ×èµ²ÎÒ£¡Æ©Èçȥ˯¾õ--! from ¡¶¾õÖ÷ÓA·
ÁîÎÒìþìý²»°²µÄ¸ßÊýѧλ֤¿¼ÊÔ¹ýÈ¥ÁË£¬½á¹û»¹ÊÇÂúÒâµÄ¡£ËäÈ»»¨ÁË3ÖܵÄʱ¼äÈ¥×¼±¸¸´Ï°Êýѧ£¬µ«ÊÇÎÒÈ´·¢ÏÖ£¬ÕæÕýȥѧϰµÄʱºòÖ»ÓÐ×îºóÄÇÁ½Ì죬ÒÔÍùµÄʱ¼äÈ«ÊÇÀ˷ѵôÁË¡£ËìÃ÷
°×£¬ÎªÊ²Ã´Í¬Ò»ÖÖ»·¾³ÏµÄÈË£¬ÓеijÉÁËÌì²Å£¬ÓеÄÂÙÎ ......

LinuxÏÂÓÃCÓïÑÔAPIÁ¬½ÓMySQLÊý¾Ý¿â

 ÏñPHPºÍperlÒ»Ñù£¬MySQLÒ²ÌṩµÄCÓïÑÔʹÓõÄAPI. C´úÂëµÄAPIÊÇËæMySQLÒ»Æð·¢²¼µÄ¡£ Ëü°üº¬ÔÚmysqlclient¿âÖУ¬ ¿ÉÒÔʹC³ÌÐòÀ´·ÃÎÊÊý¾Ý¿â¡£
    MySQLÔ´Âë°üÖеÄÐí¶à¿Í»§¶Ë¶¼ÊÇÓÃCдµÄ¡£ Èç¹ûÄãÕýÔÚÕÒʹÓÃÕâЩC APIµÄÀý×Ó£¬ ¿ÉÒÔ¿´¿´¿Í»§¶ËµÄд·¨¡£Äã¿ÉÒÔÔÚMySQLÔ´Âë°üµÄclientsĿ¼ÕÒµ½ÕâЩÀý×Ó¡£
& ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ