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

python Îļþ±¸·Ý´íÎó

#! c:\python26
# Filename: backup_ver1.py
import os
import time
source=[r'C:\test', r'C:\test1']
target_dir='D:\\back\\'
target=target_dir+time.strftime('%Y%m%d%H%M%S')+'.zip'
zip_command="rar a -r \"%s\" \"%s\"" %(target,''.join(source))
if os.system(zip_command)==0:
  print'successful backup to',target
else:
  print'backup failed'

ÔÚdosÏÂÔËÐУ¬Ìáʾ¡°²»ÄܶÁÈ¡c:\testc:\test1µÄÄÚÈÝ¡± £¬Èç¹û¸ÄΪ¡°source=r'C:\test'¡± £¬Ö»±¸·ÝÒ»¸öĿ¼£¬¿ÉÒÔÔËÐС£
²»ÖªµÀÔõô½â¾ö
''.join(source)

==>

' '.join(source)

¼Ç×ÅÁ½¸öµ¥ÒýºÅÖмäÊǸö¿Õ¸ñ¡£

Èç¹ûÊÇ¿Õ¸ñ£¬ÔÚdosÔËÐÐÌáʾ¡°ÕÒ²»µ½Ö¸¶¨Â·¾¶¡±£¬²»ÄÜ¿Õ¸ñµÄ

Âß¼­ÓеãÎÊÌ⣬Õâ¸öÓ¦¸ÃÄܹ¤×÷£º

zip_command="rar a -r \"%s\" \"%s\"" % (target, "\" \"".join(source))

ºÇºÇ,ºÍÎÒÒ»ÑùÒ²ÔÚѧÕâ½ÚÄØ
{{


Ïà¹ØÎÊ´ð£º

PythonÖеÄUnicodeÔÚDelphiÈçºÎ»¹Ô­³ÉGb2312£¿

ÒÑÖªPython ÖУº
s = unicode("²âÊÔ", "gb2312")
s = u'\u6d4b\u8bd5'
print s
²âÊÔ

ÔÚDelphiÀïÃæÈçºÎ½«\u6d4b\u8bd5ÕâÑùµÄ»¹Ô­³ÉGb2312µÄºº×ÖÄØ£¿
ÕÒµ½¸ö·½·¨
......

python PILÄ£¿é´ò¿ªÍ¼Æ¬ÎÊÌâ

ÇëÎÊÏ£¬ÎÒµÄÊÇpython2.5°²×°ÁËPILÄ£¿é£¬È»ºó±àд³ÌÐò´ò¿ª±¾»úÉϵÄÒ»¸öͼƬʱ£¬ÎªÊ²Ã´ÀϳöÏÖ´íÎóÄØ£¬ÀÏÊÇÕÒ²»µ½Í¼Æ¬£¬´íÎóÌáʾÈçÏ£ºFile "C:\Python25\Lib\site-packages\PIL\Image.py", line 1888, in o ......

³ÏÕÐPython³ÌÐòÔ±²ÎÓë¼ÆËã»úÊé¼®³ö°æ

ÓźñµÄ¸å³ê£¬³ÏÕÐPython¼¼ÊõÈËÔ±²ÎÓë¸÷ÖÖ¼¼ÊõÊé¼®³ö°æ¡£ 
ͨ¹ý¸ÃÊé¼®£¬×÷Õß¿ÉÒԵõ½Èçϱ¨³ê£º 
1¡¢·áºñµÄ¸å³ê¡£ 
2¡¢Êé¼®Öø×÷µÄÊðÃûȨ¡£ 
3¡¢¶Ô×÷ÕߺÍÊé½øÐÐÐû´«£¬Ìá¸ß×÷ÕßÔÚ¼¼ÊõȦ×ÓÀ ......

È¡µÃPython´úÂë¶ÎµÄÕýÔò±í´ïʽ?

È磺
def aa(i):
print i
a=[1,2,3]
b=2
c=3
ÄÜʶ±ð³öÆðʼλdef aa(i):
ºÍ½áÊøλ" a=[1,2,3]"£¿
ÏñPython¶ÔÓï·¨ÕâôҪÇóÑϸñµÄÎÒ¾õµÃ¾Í²»ÒªÓÃÕýÔòÁË£¬Ð§Âʲ»¸ß¡£Ö±½ÓÓÃÅжϾͿÉÒÔÁË£¬Î ......

python½âÎöxmlÎļþ

ʹÓÃxml.dom½âÎö¼¸Õ×µÄxmlÎļþ£¬·Ç³£»ºÂý£¬ÓÐÖÖ¼ÙËÀµÄ¸Ð¾õ¡£Ôõô½â¾ö£¿ÓÃÆäËû¿âÊÇ·ñ»áºÃЩ£¬ÔÝʱֻ֪µÀÕâ¸ö¿âµÄ¡£
Äã¿ÉÒÔÊÔÒ»ÏÂElementTree


pythonµÄ¹Ù·½Àý×Ó
import xml.parsers.expat

# 3 handler ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ