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

ʵս¹¹½¨PythonºÍC++»ìºÏϵͳ

      ¹ØÓÚC++ºÍPythonÖ®¼ä»¥Ïàµ÷ÓõÄÎÊÌ⣬¿ÉÒÔ²éÕÒµ½ºÜ¶à×ÊÁÏ¡£±¾ÎĽ«Ö÷Òª´Ó½â¾öʵ¼ÊÎÊÌâµÄ½Ç¶È¿´ÈçºÎ¹¹½¨Ò»¸öPythonºÍC++»ìºÏϵͳ¡£
                                         Á¦Îª 2009
 
Ò»¡¢¸ÅÄî
    »ìºÏϵͳ£º²ÉÓöàÖÖÓïÑÔ¹¹½¨µÄϵͳ¡£±ÈÈçNative C++ºÍdotNetµÄ»ìºÏϵͳ£¬Python/LuaºÍC++µÄ»ìºÏϵͳ¡£
PythonºÍC++¸÷Óи÷µÄÓÅȱµã£¬¹¹½¨Á½Õß»ìºÏϵͳµÄÖ÷ҪĿµÄ¾ÍÊÇÀûÓÃPythonµÄÁé»îÐÔºÍC++¸ßЧÐÔ£¬Ôö¼Ó³ÌÐòµÄÀ©Õ¹ÐÔ¡£µ±È»»¹ÓÐÆäËûºÃ´¦£¬´Ë´¦¾Í²»Õ¹¿ªÌ¸ÁË¡£½Å±¾ÓïÑÔÓкܶ࣬ÖÁÓÚΪʲô²»²ÉÓÃÆäËûµÄ£¨ÈçLua¡¢RubyµÈ£©£¬ÕâÀïÒ²²»¿¼ÂÇ¡£½Å±¾ÓïÑԵIJÉÓÃÖ÷ÒªÊǸöÈËϲºÃµÄÎÊÌâ¡£²ÉÓÃLua¿ÉÒԲ鵽ºÜ¶à×ÊÁÏ£¬ÒÔÇ°Ò²ÔøÓÃLuaBindʵÏÖ¹ý¡£
      
¶þ¡¢ÏµÍ³¼Ü¹¹
       »ìºÏϵͳ¿ÉÒÔ¼ò»¯³ÉÈçÏÂÄ£ÐÍ£º
 
 
 
ϵͳµÄÔËÐйý³ÌΪ£º
Ê×ÏÈÔÚÓ¦ÓóÌÐòÖÐǶÈë½Å±¾ÓïÑÔ½âÎöÆ÷£¬È»ºóÓýű¾ÓïÑÔÌṩµÄC/C++ API·â×°ÒÑÓеÄC++¹¦Äܿ⣬ÔÙÓýű¾µ÷Ó÷â×°µÄ·þÎñ¡£´Ëºó£¬Ó¦Óòã±ã¿ÉÒÔÖ´Ðнű¾ÀïµÄÄÚÈÝ£¬ÆäЧ¹ûÓëÓ¦ÓòãÖ±½Óµ÷Ó÷þÎñ²ãÀàËÆ¡£
 
Èý¡¢ÊµÏÖ
±¾ÀýÖвÉÓýű¾ÓïÑÔPython£¬Òò´ËÖ÷Òª¹¤×÷ΪÔÚÓ¦ÓòãǶÈëPython½âÎöÆ÷£¬ÓÃPython·â×°·þÎñ²ã¡£ÎªÁË˵Ã÷ÎÊÌ⣬ӦÓòãµÄʵÏÖΪPythonConsole.ex£¬·þÎñ²ãµÄʵÏÖΪMythma.dll£¬·â×°²ãΪMythmaPy.dll¡£
 
 
 
1¡¢¼Ù¶¨Mythma.dllÖеÄÒ»¸öÀàΪCHelloWorld£º
 
class MythmaAPI CHelloWorld
{
public:
   CHelloWorld(void);
   ~CHelloWorld(void);
   void SetId(int nId) { m_Id = nId;}
   int  GetId() const { return m_Id; }
private:
   int m_Id;
};
 
 
2¡¢ÏÖÔÚÓÃBoost.Python·â×°¸ÃÀࣺ
#include "HelloWorld.h"
#include <boost/python.hpp>
using namespace boost::python;
BOOST_PYTHON_MODULE(My


Ïà¹ØÎĵµ£º

PythonÏ̱߳à³Ì£¨¶þ£©Ïß³Ìͬ²½

¶à¸öÖ´ÐÐÏ߳̾­³£Òª¹²ÏíÊý¾Ý£¬Èç¹û½ö½ö¶ÁÈ¡¹²ÏíÊý¾Ý»¹ºÃ£¬µ«ÊÇÈç¹û¶à¸öÏß³ÌÒªÐ޸Ĺ²ÏíÊý¾ÝµÄ»°¾Í¿ÉÄܳöÏÖÎÞ·¨Ô¤ÁϵĽá¹û¡£
    ¼ÙÈçÁ½¸öÏ̶߳ÔÏót1ºÍt2¶¼Òª¶ÔÊýÖµnum=0½øÐÐÔö1ÔËË㣬ÄÇôt1ºÍt2¶¼¸÷¶ÔnumÐÞ¸Ä10´ÎµÄ»°£¬ÄÇônum×îÖյĽá¹ûÓ¦¸ÃΪ20¡£µ«ÊÇÈç¹ûµ±t1È¡µÃnumµÄֵʱ£¨¼ÙÈç´ËʱnumΪ0£©£¬ÏµÍ³°Ñt1µ ......

PythonÏ̱߳à³Ì£¨Èý£©Í¬²½¶ÓÁÐ

ÎÒÃǾ­³£»á²ÉÓÃÉú²úÕß/Ïû·ÑÕß¹ØϵµÄÁ½¸öÏß³ÌÀ´´¦ÀíÒ»¸ö¹²Ïí»º³åÇøµÄÊý¾Ý¡£ÀýÈçÒ»¸öÉú²úÕßÏ߳̽ÓÊÜÓû§Êý¾Ý·ÅÈëÒ»¸ö¹²Ïí»º³åÇøÀµÈ´ýÒ»¸öÏû·ÑÕßÏ̶߳ÔÊý¾ÝÈ¡³ö´¦Àí¡£µ«ÊÇÈç¹û»º³åÇøµÄ̫С¶øÉú²úÕߺÍÏû·ÑÕßÁ½¸öÒì²½Ï̵߳ÄËٶȲ»Í¬Ê±£¬ÈÝÒ׳öÏÖÒ»¸öÏ̵߳ȴýÁíÒ»¸öÇé¿ö¡£ÎªÁ˾¡¿ÉÄܵÄËõ¶Ì¹²Ïí×ÊÔ´²¢ÒÔÏàͬËٶȹ¤×÷µÄ¸÷Ï̵߳ĵ ......

pythonÀàÐÍת»»£¬ÊýÖµ²Ù×÷(ת)


http://hi.baidu.com/guzhilei1986/blog/item/8969b4debe99e150ccbf1ae7.html
º¯Êý                       ÃèÊö  
int(x [,base ])          ......

python ¶à¼Ì³Ð(2)

from:  http://www.chinesepython.org/pythonfoundry/tut2.3/tmp/multiple.html
9.5.1 ¶à¼Ì³Ð Multiple Inheritance
Python supports a limited form of multiple inheritance as well. A class definition with multiple base classes looks as follows:
PythonͬÑùÓÐÏÞµÄÖ§³Ö¶à¼Ì³ÐÐÎʽ¡£¶à¼Ì³ÐµÄÀඨÒåÐÎÈçÏÂÀ ......

pythonÖÐʹÓ÷½±ãµÄLIST¶ÔÏó

×î½ü¶Ôpython²úÉúÁËÐËȤ£¬ÓÚÊÇ´ÓÍøÉÏÏÂÔØÁË»ù±¾PYTHONµÄÊéºÍÎĵµ£¬¿ªÊ¼ÁËPYTHONµÄѧϰ£¬·¢ÏÖPYTHONÖеÄlist¶ÔÏóµÄ¹¦ÄÜʵÔÚÊǷdz£Ç¿´ó£¬±à³ÌÆðÀ´±ÈÆäËûµÄ³ÌÐòÓïÑÔ¶ÔÁбíµÄ²Ù×÷Òª·½±ãµÄ¶à¡£
ÔÚpythonÖж¨ÒåÒ»¸öÁбíÖ»ÐèÒªÈçÏÂÓï¾ä
li = ["a","b","c","d"]
listÓÐÐí¶àµÄº¯Êý¿ÉÒÔÓÃÀ´½øÐжÔÁбíµÄ²Ù×÷£¬Èçextend,append,inse ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ