ʹÓÃpy2exe´ò°üpython½Å±¾£¨except 2.6£©
Ò»¡¢¼ò½é
py2exeÊÇÒ»¸ö½«python½Å±¾×ª»»³ÉwindowsÉϵĿɶÀÁ¢Ö´ÐеĿÉÖ´ÐгÌÐò(*.exe)µÄ¹¤¾ß£¬ÕâÑù£¬Äã¾Í¿ÉÒÔ²»ÓÃ×°python¶øÔÚwindowsϵͳÉÏÔËÐÐÕâ¸ö¿ÉÖ´ÐгÌÐò¡£
py2exeÒѾ±»ÓÃÓÚ´´½¨wxPython,Tkinter,Pmw,PyGTK,pygame,win32com clientºÍserver,ºÍÆäËüµÄ¶ÀÁ¢³ÌÐò¡£py2exeÊÇ·¢²¼ÔÚ¿ªÔ´Ðí¿É֤ϵġ£
¶þ¡¢°²×°py2exe
´Óhttp://prdownloads.sourceforge.net/py2exeÏÂÔز¢ÔËÐÐÓëÄãËù°²×°µÄPython¶ÔÓ¦µÄpy2exe°æ±¾µÄ installer£¬Õ⽫°²×°py2exeºÍÏàÓ¦µÄÀý×Ó£»ÕâЩÀý×Ó±»°²×°ÔÚlib\site-packages\py2exe\samplesĿ¼Ï¡£
Èý¡¢py2exeµÄÓ÷¨
Èç¹ûÄãÓÐÒ»¸öÃûΪmyscript.pyµÄpython½Å±¾£¬ÄãÏë°ÑËüת»»ÎªÔËÐÐÔÚwindowsÉϵĿÉÖ´ÐгÌÐò£¬²¢ÔËÐÐÔÚûÓа²×°pythonµÄ windowsϵͳÉÏ£¬ÄÇôÊ×ÏÈÄãӦдһ¸öÓÃÓÚ·¢²¼³ÌÐòµÄÉèÖýű¾ÀýÈçmysetup.py£¬ÔÚÆäÖеÄsetupº¯ÊýÇ°²åÈëÓï¾äimport py2exe ¡£
mysetup.pyʾÀýÈçÏÂ:
# mysetup.py
from distutils.core import setup
import py2exe
setup(console=["myscript.py"])
È»ºó°´ÏÂÃæµÄ·½·¨ÔËÐÐmysetup.py:
python mysetup.py py2exe
ÉÏÃæµÄÃüÁîÖ´Ðк󽫲úÉúÒ»¸öÃûΪdistµÄ×ÓĿ¼£¬ÆäÖаüº¬ÁËmyscript.exe,python24.dll,library.zipÕâЩÎļþ¡£
Èç¹ûÄãµÄmyscript.py½Å±¾ÖÐÓÃÁËÒѱàÒëµÄCÀ©Õ¹Ä£¿é£¬ÄÇôÕâЩģ¿éÒ²»á±»¿½±´ÔÚ¸ö×ÓĿ¼ÖУ¬Í¬Ñù£¬ËùÓеÄdllÎļþÔÚÔËÐÐʱ¶¼ÊÇÐèÒªµÄ£¬³ýÁËϵͳµÄdllÎļþ¡£
dist×ÓĿ¼ÖеÄÎļþ°üº¬ÁËÄãµÄ³ÌÐòËù±ØÐëµÄ¶«Î÷£¬ÄãÓ¦½«Õâ¸ö×ÓĿ¼ÖеÄËùÓÐÄÚÈÝÒ»Æð·¢²¼¡£
ĬÈÏÇé¿öÏ£¬py2exeÔÚĿ¼distÏ´´½¨ÒÔÏÂÕâЩ±ØÐëµÄÎļþ£º
1¡¢Ò»¸ö»ò¶à¸öexeÎļþ¡£
2¡¢python##.dll¡£
3¡¢¼¸¸ö.pydÎļþ£¬ËüÃÇÊÇÒѱàÒëµÄÀ©Õ¹Ãû£¬ËüÃÇÊÇexeÎļþËùÐèÒªµÄ£»¼ÓÉÏÆäËüµÄ.dllÎļþ£¬ÕâЩ.dllÊÇ.pydËùÐèÒªµÄ¡£
4¡¢Ò»¸ölibrary.zipÎļþ£¬Ëü°üº¬ÁËÒѱàÒëµÄ´¿µÄpythonÄ£¿éÈç.pyc»ò.pyo
ÉÏÃæµÄmysetup.py´´½¨ÁËÒ»¸ö¿ØÖÆ̨µÄmyscript.exe³ÌÐò£¬Èç¹ûÄãÒª´´½¨Ò»¸öͼÐÎÓû§½çµÄ³ÌÐò£¬ÄÇôÄãÖ»ÐèÒª½«mysetup.pyÖеÄconsole=["myscript.py"]Ì滻Ϊwindows=["myscript.py"]¼È¿É¡£
py2exeÒ»´ÎÄܹ»´´½¨¶à¸öexeÎļþ£¬ÄãÐèÒª½«ÕâЩ½Å±¾ÎļþµÄÁÐ±í´«µÝ¸øconsole»òwindowsµÄ¹Ø¼ü×Ö²ÎÊý¡£Èç¹ûÄãÓм¸¸öÏà¹ØÁªµÄ½Å±¾£¬ÄÇôÕâÊǺÜÓÐÓõġ£
ÔËÐÐÏÂÃæ¸öÃüÁ½«ÏÔʾpy2exeÃüÁîµÄËùÓÐÃüÁîÐбê¼Ç¡£
python mysetup.py py2exe --help
ËÄ¡¢Ö¸¶¨¶îÍâµÄÎļþ
һЩӦÓóÌÐòÔÚÔËÐÐʱÐèÒª¶îÍâµÄÎļþ£¬ÖîÈçÅäÖÃÎ
Ïà¹ØÎĵµ£º
¿É¶ñ¡¢¿É±¯¡¢¿É³Ü¡¢¿ÉÁ¯¡¢¿É̾¡¢¿ÉЦ£¡£¡£¡
2009Äê10ÔÂ15ÈÕ£¬Ò»¸öÁî¹ã´ópython±à³Ì¹¤×÷°®ºÃÕß¿ÞЦ²»µÃµÄÊ·¢ÉúÁË——pythonµÄ¹Ù·½ÍøÕ¾£¨http://www.python.org£©±»Î°´óµÄÌ쳯¸ø·âÁË£¡
µ±Ê±£¬ÓÐÈË˵ÊÇÒòΪÓÐÒ»¸öHÍøÕ¾ºÍpythonµÄ¹ÙÍøºÜÏñ£¬·â´íÁË¡£ÓÚÊÇ£¬ÎÒÊÔ×Å´ò¿ªÁËÄǸö“ÏàËƵÄÍøÕ¾http://www.python.com ......
from random import randint #µ¼ÈëËæ¼´º¯Êý
def guessNum(): &nbs ......
Õâ¸öÊÇ1.10°æ±¾µÄ²ÂÊý×Ö£¬ËäÈ»´úÂë»ù±¾²»±ä£¬µ«ÊDZäµÄÊÇ˼ά·½Ê½£¬²»ÔÙÊÇÓÃÃæÏò¹ý³ÌµÄ·½·¨£¬¶ø¸ÃΪÓÃÀàÀ´ÊµÏÖ£¬±È½ÏÇ°ºóµÄ´úÂ룬ÕâÒ»¸ö¼ò½à¶àÁË£¬¶øÇÒ¸üÈÝÒ×Àí½â£¡
¸üУº
#1.0°æ±¾ÖеÄÌáʾÀàÐÍÊÇ£ºAABB£¬¼òµ¥µÄ˵¾ÍÊÇÏà¶ÔλÖõÄÊý×Ö¶ÔÁ˾ÍÏÔʾA£¬´íÁ˾ÍÏÔʾB£»
#ÏÖÔÚµÄÌáʾ¸ÄΪ£º0A4B¸ñʽ£¬Ò²¾ÍÊÇ˵²»ÌáʾÄǸöλÖõÄÊý× ......
ÔÚparamikoÖÐʹÓÃÓû§ÃûºÍÃÜÂëͨ¹ýsftp´«ÊäÎļþ£¬²»Ê¹ÓÃkeyÎļþ¡£
import getpass
import select
import socket
import traceback
import paramiko
def putfile():
#import interactive
# setup logging
paramiko.util.log_to_file('demo.log')
username = username
hostname = hostname
......
½ñÌìͻȻÓÐÒ»¸öÏë·¨£¬¾ÍÊÇÏë×Ô¼ºÐ´Ò»¸ö·Òë½Å±¾¡£¿ÉϧGoogleÌṩµÄAPIÊǹ©ÍøÂçÓ¦Óõġ£¸ÕºÃÔÚ¡¶dive into python¡·ÀïÃæÕâ±¾ÊéÀïÃæ¿´µ½ÈçºÎ´ÓHTMLÎĵµÖÐÌáÈ¡³öÀ´×Ô¼ºÏëÒªµÄÄÚÈÝ£¬ÄÇÕâÑùµÄ»°£¬¿É²»¿ÉÒÔÄ£Äâä¯ÀÀÆ÷À´·¢ËÍÏë·ÒëµÄ¾ä×Ó£¬È»ºóÔÙ½ÓÊÕ·µ»Ø½á¹ûºóµÄHTMLÔ´Â룬×îºó´ÓÖÐÌáÈ¡³ö·ÒëµÄ½á¹ûÄØ£¿¡¡¡¡ÆäʵÊÇÐеģ¬ÒòΪÀûÓ ......