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

python¶ÁдÎļþ


1.open
ʹÓÃopen´ò¿ªÎļþºóÒ»¶¨Òª¼ÇµÃµ÷ÓÃÎļþ¶ÔÏóµÄclose()·½·¨¡£±ÈÈç¿ÉÒÔÓÃtry/finallyÓï¾äÀ´È·±£×îºóÄܹرÕÎļþ¡£
file_object = open('thefile.txt')
try:
     all_the_text = file_object.read( )
finally:
     file_object.close( )
×¢£º²»ÄÜ°ÑopenÓï¾ä·ÅÔÚtry¿éÀÒòΪµ±´ò¿ªÎļþ³öÏÖÒ쳣ʱ£¬Îļþ¶ÔÏófile_objectÎÞ·¨Ö´ÐÐclose()·½·¨¡£
2.¶ÁÎļþ
¶ÁÎı¾Îļþ
input = open('data', 'r')
#µÚ¶þ¸ö²ÎÊýĬÈÏΪr
input = open('data')
 
¶Á¶þ½øÖÆÎļþ
input = open('data', 'rb')
 
¶ÁÈ¡ËùÓÐÄÚÈÝ
file_object = open('thefile.txt')
try:
     all_the_text = file_object.read( )
finally:
     file_object.close( )
 
¶Á¹Ì¶¨×Ö½Ú
file_object = open('abinfile', 'rb')
try:
    while True:
         chunk = file_object.read(100)
        if not chunk:
            break
         do_something_with(chunk)
finally:
     file_object.close( )
 
¶ÁÿÐÐ
list_of_all_the_lines = file_object.readlines( )
Èç¹ûÎļþÊÇÎı¾Îļþ£¬»¹¿ÉÒÔÖ±½Ó±éÀúÎļþ¶ÔÏó»ñȡÿÐУº
for line in file_object:
     process line
 
3.дÎļþ
дÎı¾Îļþ
output = open('data', 'w')
 
д¶þ½øÖÆÎļþ
output = open('data', 'wb')
 
×·¼ÓдÎļþ
output = open('data', 'w+')
 
дÊý¾Ý
file_object = open('thefile.txt', 'w')
file_object.write(all_the_text)
file_object.close( )
 
дÈë¶àÐÐ
file_object.writelines(list_of_text_strings)
×¢Ò⣬µ÷ÓÃwritelinesдÈë¶àÐÐÔÚÐÔÄÜÉÏ»á±ÈʹÓÃwriteÒ»´ÎÐÔдÈëÒª¸ß¡£
ÔÚ´¦ÀíÈÕÖ¾ÎļþµÄʱºò£¬³£³£»áÓöµ½ÕâÑùµÄÇé¿ö£ºÈÕÖ¾Îļþ¾Þ´ó£¬²»¿


Ïà¹ØÎĵµ£º

Eclipse Python¿ª·¢»·¾³

1£¬ÏÂÔØorg.python.pydev.feature-1.5.0.1251989166.zip http://sourceforge.net/projects/pydev/files/
2£¬°²×°²å¼þµ½eclipse
3£¬ÖØÆôeclipse
×¢Ò⣺ʹÓÃ1.5.6°æ±¾pydev²å¼þ£¬´´½¨python¹¤³Ì»á±¨´í£¬Ê¹ÓÃ1.5.0°æ±¾ÎÞ´ËÎÊÌâ¡£ ......

LinuxÏÂpython lxmlÄ£¿éµÄ°²×°

ÐèÒªÏÈ°²×°libxml2-devel libxslt-develÕâÁ½¸örpm°ü£¬Èç¹ûʹÓ÷ÇrootÓû§°²×°£¬¿ÉÒÔÏÂÔØlibxml2ºÍlibxsltµÄÔ´´úÂë½øÐа²×°¡£ libxml2-devel¡¢libxslt-devel×°ºÃºó£¬½âѹlxmlµÄ°ü£¬Çл»µ½Õâ¸ö°üµÄ·¾¶¡£
¼ÓÈëCFLAGS½øÐбàÒëºÍ°²×°£¬ÔÚshellÏÂÒÀ´ÎÊäÈëÈçÏÂÃüÁ CFLAGS=-I/usr/include/libxml2:/usr/include/libxslt/ ......

±àÒëÁËwindowsϵÄpython3Á¬½ÓMysqlµÄ¿âmypysql


±àÒëÁËÒ»¸öwindowsϵÄpython3Á¬½ÓMysqlµÄ¿â
mypysql
°æ±¾ÊÇ 0.5.1 £¬¸ù¾Ý¹Ù·½µÄÐÞ¸ÄÈÕÖ¾£¬Õâ¸ö°æ±¾ÐÞ¸ÄÁË0.5ÖÐÒ»¸öÄÚ´æй©ÎÊÌâ¡£
Ô´´úÂëºÍ±àÒëºóµÄÎļþΪ£º
http://211.147.215.55/down/mypysql-0.5.1-win.zip
mypysqlµÄ¹Ù·½µØÖ· https://sourceforge.net/projects/mypysql/
......

Python£¬¼òµ¥µÄÁ¦Á¿

Python£¬¼òµ¥µÄÁ¦Á¿
¶¹°êÍø¶Ô»¥ÁªÍøÓû§À´ËµÊÇÖªÃûµÄWeb 2.0ÉçÇø£¬µ«¶Ô¿ª·¢Õ߶øÑÔ£¬¸üÖØÒªµÄÊÇÒ»¸öÓ¦ÓÃPython´òÔìµÄ·Ç³£³É¹¦µÄWeb 2.0Õ¾µã¡£
Pythonµ®ÉúÒÑÓÐ20ÄêµÄÀúÊ·£¬Ä¿Ç°¹úÄÚµÄPython·¢Õ¹×´¿öÈçºÎ£¿ÓëÆäËûÓïÑÔ£¨Æ½Ì¨£©Ïà±È£¬PythonÓÐÄÄЩÏÔ¶øÒ×¼ûµÄÓŵ㣿¶¹°êÓ¦ÓÃPython½øÐÐWeb¿ª·¢ÓÐÄÄЩ³É¹¦¾­Ñé¿ÉÒÔ½è¼ø£¿´ø×ÅÕâЩΠ......

¡¶Dive Into Python¡··ÇËÀ²»¿É

ÒëÕßÑÔ£º
ÔçÔÚ 2008 Äê 8 Ô£¬ÎÒ¾ÍÔøÔÚ×Ô¼ºµÄ²©¿Í·¢±íÁËһƪ¡¶ÎªÊ²Ã´<Dive into Python>²»ÖµµÃÍƼö¡·£¨http://blog.csdn.net/lanphaday/archive/2008/08/28/2845258.aspx
£©£¬µ±Ê±ÒýÆðµÄÌÖÂ۾Ͳ»¶à˵ÁË£¬²»¹ýÊÂʵÉϵ½½ñÌìÈÔÈ»ÓÐÐí¶àÅóÓÑÁôÑÔÓëÎÒÌÖÂÛ£¬ÈÃÎÒ¼¸´ÎÔôÐIJ»ËÀ£¬ÏëдÔÙÉîÈëÅúÅС£ºÃÔ˵ÄʱºòÔÚÎÒÕæÕýÔÜ×㶯Á ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ