python´¦ÀízipÎļþ£¨×ª£© 2009
ת×Ô http://hi.baidu.com/xunxun129/blog/item/3befad0f8ff992c07bcbe180.html
ÓÐʱÎÒÃÇÐèÒªÔÚ Python
ÖÐʹÓà zip Îļþ£¬¶øÔÚ1.6°æÖУ¬Python ¾ÍÒѾÌṩÁË zipfile Ä£¿é¿ÉÒÔ½øÐÐÕâÑùµÄ²Ù×÷¡£²»¹ý Python ÖеÄ
zipfile Ä£¿é²»ÄÜ´¦Àí¶à¾íµÄÇé¿ö£¬²»¹ýÕâÖÖÇé¿ö²¢²»¶à¼û£¬Òò´ËÔÚͨ³£Çé¿öÏÂÒѾ×㹻ʹÓÃÁË¡£ÏÂÃæÎÒÖ»ÊǶÔһЩ»ù±¾µÄ zipfile
²Ù×÷½øÐÐÁ˼Ǽ£¬×ãÒÔÓ¦¸¶´ó²¿·ÖµÄÇé¿öÁË¡£
zipfile Ä£¿é¿ÉÒÔÈÃÄã´ò¿ª»òдÈëÒ»¸ö zip Îļþ¡£±ÈÈ磺
import zipfile
z = zipfile.ZipFile('zipfilename', mode='r')
ÕâÑù¾Í´ò¿ªÁËÒ»¸ö zip Îļþ£¬Èç¹ûmodeΪ'w'»ò'a'Ôò±íʾҪдÈëÒ»¸ö zip Îļþ¡£Èç¹ûÊÇдÈ룬Ôò»¹¿ÉÒÔ¸úÉϵÚÈý¸ö²ÎÊý£º
compression=zipfile.ZIP_DEFLATED
»ò
compression=zipfile.ZIP_STORED
ZIP_DEFLATEDÊÇѹËõ±êÖ¾£¬Èç¹ûʹÓÃËüÐèÒª±àÒëÁËzlibÄ£¿é¡£¶øºóÒ»¸öÖ»ÊÇÓÃzip½øÐдò°ü£¬²¢²»Ñ¹Ëõ¡£
ÔÚ´ò¿ªÁËzipÎļþÖ®ºó¾Í¿ÉÒÔ¸ù¾ÝÐèÒªÊǶÁ³özipÎļþµÄÄÚÈÝ»¹Êǽ«ÄÚÈݱ£´æµ½ zip ÎļþÖС£
¶Á³özipÖеÄÄÚÈÝ
ºÜ¼òµ¥£¬zipfile ¶ÔÏóÌṩÁËÒ»¸öread(name)µÄ·½·¨¡£nameΪzipÎļþÖеÄÒ»¸öÎļþÈë¿Ú£¬Ö´ÐÐÍê³ÉÖ®ºó£¬½«·µ»Ø¶Á³öµÄÄÚÈÝ£¬Äã°ÑËü±£´æµ½Ïëµ½µÄÎļþÖм´¿É¡£
дÈëzipÎļþ
ÓÐÁ½ÖÖ·½Ê½£¬Ò»ÖÖÊÇÖ±½ÓдÈëÒ»¸öÒѾ´æÔÚµÄÎļþ£¬ÁíÒ»ÖÖÊÇдÈëÒ»¸ö×Ö·û´®¡£
¶Ô
ÓÚµÚÒ»ÖÖʹÓà zipfile ¶ÔÏóµÄ write(filename, arcname,
compress_type)£¬ºóÁ½¸ö²ÎÊýÊÇ¿ÉÒÔºöÂԵġ£µÚÒ»¸ö²ÎÊýÊÇÎļþÃû£¬µÚ¶þ¸ö²ÎÊýÊDZíʾÔÚ zip
ÎļþÖеÄÃû×Ö£¬Èç¹ûûÓиø³ö£¬±íʾʹÓÃÓëfilenameÒ»ÑùµÄÃû×Ö¡£compress_typeÊÇѹËõ±êÖ¾£¬Ëü¿ÉÒÔ¸²¸Ç´´½¨ zipfile
ʱµÄ²ÎÊý¡£µÚ¶þÖÖÊÇʹÓà zipfile ¶ÔÏóµÄ writestr(zinfo_or_arcname, bytes)£¬µÚÒ»¸ö²ÎÊýÊÇ
zipinfo ¶ÔÏó»òдµ½Ñ¹ËõÎļþÖеÄѹËõÃû£¬µÚ¶þ¸ö²ÎÊýÊÇ×Ö·û´®¡£Ê¹ÓÃÕâ¸ö·½·¨¿ÉÒÔ¶¯Ì¬µÄ×éÖ¯ÎļþµÄÄÚÈÝ¡£
ÐèҪעÒâµÄÊÇÔÚ¶Á³öʱ£¬ÒòΪֻÄܶÁ³öÄÚÈÝ£¬Òò´ËÈç¹ûÏëʵÏÖ°´Ä¿Â¼½á¹¹Õ¹¿ª zip ÎļþµÄ»°£¬ÕâЩ²Ù×÷ÐèÒª×ÔÒÑÀ´Íê³É£¬±ÈÈç´´½¨Ä¿Â¼£¬´´½¨Îļþ²¢Ð´Èë¡£¶øдÈëʱ£¬Ôò¿ÉÒÔ¸ù¾ÝÐèÒª¶¯Ì¬×éÖ¯ÔÚ zip ÎļþÖеÄĿ¼½á¹¹£¬ÕâÑù¿ÉÒÔ²»°´ÕÕÔÀ´µÄĿ¼½á¹¹À´Éú³É zip Îļþ¡£
ÓÚÊÇÎÒΪÁË·½±ãʹÓ㬴´½¨ÁË×ÔÒѵÄÒ»¸ö ZFile À࣬Ö÷ÒªÊÇʵÏÖÏó winrar µÄÓÒ¼ü²Ëµ¥ÖеÄѹËõµ½µÄ¹¦ÄÜ--¼´½«Ò»¸özipÎļþѹËõµ½Ö¸¶¨Ä¿Â¼£¬×Ô¶¯´´½¨ÏàÓ¦µÄ×ÓĿ¼¡£ÔÙÓоÍÊÇ·½±ãÉú³É zip Îļþ¡£ÀàÔ´ÂëΪ£º
import zipfile
import os.path
i
Ïà¹ØÎĵµ£º
Ò»¸öPython½Å±¾µÄ¿ª·¢È«¹ý³Ì
ÎÊÌ⣺Íê³ÉÒ»¸ö¿ÉÒÔΪÎÒÃÇËùÓеÄÖØÒª³ÌÐò×ö±¸·ÝµÄ³ÌÐò¡£
²½Öè²ð½â£º
ÐèÒª±¸·ÝµÄÎļþºÍĿ¼ÓÉÒ»¸öÁбíÖ¸¶¨¡£
Îļþ±¸·Ý³ÉÒ»¸özipÎļþ¡£
zip´æµµµÄÃû³ÆÊǵ±Ç°µÄÈÕÆÚºÍʱ¼ä¡£
ÎÒÃÇʹÓñê×¼µÄzipÃüÁËüͨ³£Ä¬ÈϵØËæLinux/Unix·¢ÐаæÌṩ¡£WindowsÓû§¿ÉÒÔʹÓÃInfo-Zip³ÌÐò¡£×¢Òâ ......
ѧϰÁ˵ڰËÕº󣬽ôÂàÃܹĵĿªÊ¼µÚ¾ÅÕµÄѧϰ¡£
ѧϰÁË“Êý¾Ý½á¹¹²Ù×÷”£¬Ñ§Ï°ÁË“Îļþ²Ù×÷”¡£“Êý¾Ý½á¹¹²Ù×÷”»¹±È½ÏÓÐÒâ˼£¬¿´µÃ¶®¡£“Îļþ²Ù×÷”¾Í¿ªÊ¼Í·»è»èµÄ£¬ÏñÄÔ×Ó½øÁ˽¬ºý¡£
ºÃ²»ÈÝÒ׿´µ½“²Ù×÷³ÌÐò”£¬²Å·¢ÏÖ“²Ù×÷³ÌÐò”ÕâÒ»½ÚµÄÄÚÈݲ¢²»ÊÇÎÒËù ......
http://www.cppblog.com/jacky2019/archive/2007/05/17/24269.html
c++ÖÐǶÈëpythonÈëÃÅ1
±¾ÈËÊÇÓÃvc2003+python2.5ѧϰµÄ£¬ÆäËüµÄÒ²Ó¦¸Ã²î²»Á˶àÉÙ
0. »µ¾³ÉèÖÃ
°ÑpythonµÄinclude/libsĿ¼·Ö±ð¼Óµ½vcµÄinclude/lib directoriesÖÐÈ¥¡£ÁíÍ⣬ÓÉÓÚpythonûÓÐÌṩdebug lib£¬ÌåµØ˵£¬¾ÍÊÇûÓÐÌṩpython25_d.libÁË¡£Äã¿É ......
http://www.cppblog.com/oosky/archive/2005/10/11/639.html
Lesson 1 ×¼±¸ºÃѧϰPythonµÄ»·¾³
Python µÄ¹Ù·½ÍøÖ·£º
www.python.org
µã»÷ÏÂÃæÁ¬½Ó¾Í¿ÉÒÔÖ±½ÓÏÂÔØÁË£¬ÕâÀïÖ»ÌṩÁËWindowsϵÄPython¡£
http://www.python.org/ftp/python/2.4.2/python-2.4.2.msi
linux°æ±¾µÄÎҾͲ»ËµÁË£¬ÒòΪÈç¹ûÄãÄܹ»Ê¹ÓÃlinux²¢°²×° ......
(ת)[Python ѧϰ]2.5°æyield֮ѧϰÐĵÃ
ÔÚ shhgs ·¢²¼Á˹ØÓÚ¡¶ Py 2.5 what's new Ö® yield¡·Ö®ºó£¬ÔÀ´ÎÒ²»ÊÇÌرð¹Ø×¢ yield µÄÓ÷¨£¬ÒòΪ¶ÔÓÚ2.3ÖмÓÈëµÄyieldÏà¶ÔÀ´Ëµ¹¦Äܼòµ¥£¬ËüÊÇ×÷Ϊһ¸ö generator ²»¿ÉȱÉÙµÄÒ»ÌõÓï¾ä£¬Ö»Òª°üº¬ËüµÄº¯Êý¼´ÊÇÒ»¸ö generator ¡£µ«ÔÚ2.3ÖУ¬generator ²»ÄÜÖØÈ룬²»ÄÜÔÚÔËÐй ......