python 2.5.x ÕÒ²»µ½ python25_d.lib ½â¾ö
1£® Ê×ÏȾÍÊÇÔÚ±àÒëÆ÷ÖаÑpython°²×°Ä¿Â¼include/Óëlibs/¼ÓÈ룬¶ÔÓÚÕâµãÎÒÔÚvc6ÖпÉÒÔ£¬µ«ÊÇÔÚdev c++Öм´Ê¹¼ÓÈëÁ˱àÒëÒ²»á³ö´í£¬ËµÕÒ²»µ½pythonÍ·Îļþ£¬Õâµã±È½ÏÓôÃÆ£¬²»¹ý¿¼Âǵ½Ò»°ãwindows±à³Ì¶¼ÓõÄÊÇvc£¬ËùÒÔ²¢Ã»ÓÐʲôӰÏì°É£¡£¡£¡
È»ºóÓÃ#include <Python.h>¾Í¿ÉÒÔ°ÑpythonµÄÖ÷Í·Îļþ°üº¬½øÀ´ÁË¡£
µ«ÊÇÔÚµ÷ÊÔµÄʱºò£¬»á³öÏÖ˵ÕÒ²»µ½python25_d.libµÄÁ´½Ó´íÎ󣬳öÏÖÕâ¸ö´íÎóµÄÔÒòÊÇpython_d.libÊÇ¿âµÄµ÷ÊÔºóÐÎʽ£¬µ±ÎÒÃÇÒÔdebugģʽ±àÒ빤³Ìʱ£¬python¾ÍÓÃÕâ¸ölibÎļþ£¬µ«ÊÇÕâ¸öÎļþÊDz»¿ÉÓõġ£¶ÔÓÚÕâµã£¬×î¿ìµÄ°ì·¨¾ÍÊÇÇ¿ÖÆÒªÇópythonÔÚÈκÎÇé¿ö϶¼ÊÇÓ÷ǵ÷ÊÔ°æ±¾£¬¾Í¿ÉÒÔÁË¡£Òª×öµ½ÕâÒ»µã
a£© ÔÚpythonĿ¼includeÎļþ¼ÐÏ£¬´ò¿ªpyconfig.h£¬ÕÒµ½ÈçÏÂÓï¾ä
# ifdef _DEBUG
# pragma comment(lib,"python25_d.lib")
# else
# pragma comment(lib,"python25.lib")
# endif /* _DEBUG */
½«python25_d.lib¸Ä³Épython25.lib
b£© ÕÒµ½
#ifdef _DEBUG
# define Py_DEBUG
#endif
½«ÆäÓÃ/**/ÆÁ±Î
ÕâÑù¾Í¿ÉÒÔÁË¡£
2.Ö±½Óµ½libsÎļþ¼ÐÖн«python25.lib ¸´ÖÆÒ»¸ö½Ð×öpython25_d.libÎļþµÄ·ÅÔÚlibsĿ¼ÏÂÒ²¿É±àÒë
Ïà¹ØÎĵµ£º
PythonÄÚ½¨Òì³£Ìåϵ½á¹¹
BaseException
+--¡¡SystemExit
+--¡¡KeyboardInterrupt
+--¡¡GeneratorExit
+--¡¡Exception
+--¡¡StopIteration
+--¡¡StandardError
|¡¡¡¡¡¡¡¡+--¡¡BufferError
|¡¡¡¡¡¡¡¡+--¡¡ArithmeticError
|¡¡¡¡¡¡¡¡|¡¡¡¡¡¡¡¡+--¡¡FloatingPointError
|¡¡¡¡¡¡¡¡|¡¡¡¡¡¡¡¡+--¡¡OverflowError
|¡¡¡¡ ......
µ±pythonÖм䴦Àí·ÇASCII±àÂëʱ£¬¾³£»á³öÏÖÈçÏ´íÎó£º
UnicodeDecodeError: 'ascii' codec can't decode byte 0x?? in position 1: ordinal not in range(128)
0x??Êdz¬³ö128µÄÊý×Ö£¬pythonÔÚĬÈϵÄÇé¿öÏÂÈÏΪÓïÑԵıàÂëÊÇascii±àÂ룬ËùÒÔÎÞ·¨´¦ÀíÆäËû±àÂ룬ÐèÒªÉèÖÃpythonµÄĬÈϱàÂëΪËùÐèÒªµÄ±àÂë¡£
Ò»¸ö½â¾öµÄ·½°¸ÊÇ ......
Python ÊÇÃâ·ÑµÄ½âÊÍÐÔÓïÑÔ£¬¾ßÓÐÃæÏò¶ÔÏóµÄÌØÐÔ¡£¿ÉÒÔÔËÐÐÔÚ¶àÖÖ²Ù×÷ϵͳ֮ÉÏ£¬Python¾ßÓÐÇåÎúµÄ½á¹¹£¬¼ò½àµÄÓï·¨ÒÔ¼°Ç¿´óµÄ¹¦ÄÜ¡£Python¿ÉÒÔÍê³É´ÓÎı¾´¦Àíµ½ÍøÂçͨÐŵȸ÷ÖÖ¹¤×÷£¬python×ÔÉíÒѾÌṩÁË´óÁ¿µÄÄ£¿éÀ´ÊµÏÖ¸÷ÖÖ¹¦ÄÜ£¬³ý´ËÒÔÍ⻹¿ÉÒÔʹÓÃC/C++À´À©Õ¹Python£¬ÉõÖÁ»¹¿ÉÒÔ½«PythonǶÈëµ½ÆäËûÓ ......
»°ËµPython£¨¶þ£©
×Ô´ÓС°×ÉÏÍêµÚÒ»¿Î£¬Python¼òÖ±³ÉÁËËûµÄ¿Æѧ¼ÆËãÆ÷¡£Ã¿ÌìÔçÉÏ£¬Ð¡°××ÜÊDz»Íü“Á·Ï°”Ò»ÏÂPython¡£
>>> 10000*1.2**40
14697715.679690843
“ºÙºÙ£¬ÎÒ·¢´ïÁË£¡”С°×ÔÚɵЦ×Å£¬ºÃÏñÔÚ×öÃΣ¬“ËÄÊ®Äêºó¾ÍÊÇÒÚÍò¸»ÎÌÀ²!”
С²ËÇÃÁËÇÃС°×µ ......
×ܽáÏ£¬Python ÏÂÔØÍøÒ³µÄ¼¸ÖÖ·½·¨
1
fd = urllib2.urlopen(url_link)
data = fd.read()
ÕâÊÇ×î¼ò½àµÄÒ»ÖÖ£¬µ±È»Ò²ÊÇGetµÄ·½·¨
2
ͨ¹ýGETµÄ·½·¨
def GetHtmlSource(url):
try:
htmSource = ''
&nb ......