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 ÖУº
s = unicode("²âÊÔ", "gb2312")
s = u'\u6d4b\u8bd5'
print s
²âÊÔ
ÔÚDelphiÀïÃæÈçºÎ½«\u6d4b\u8bd5ÕâÑùµÄ»¹Ô³ÉGb2312µÄºº×ÖÄØ£¿
ÕÒµ½¸ö·½·¨
......
ÇëÎÊÏ£¬ÎÒµÄÊÇpython2.5°²×°ÁËPILÄ£¿é£¬È»ºó±àд³ÌÐò´ò¿ª±¾»úÉϵÄÒ»¸öͼƬʱ£¬ÎªÊ²Ã´ÀϳöÏÖ´íÎóÄØ£¬ÀÏÊÇÕÒ²»µ½Í¼Æ¬£¬´íÎóÌáʾÈçÏ£ºFile "C:\Python25\Lib\site-packages\PIL\Image.py", line 1888, in o ......
ÓźñµÄ¸å³ê£¬³ÏÕÐPython¼¼ÊõÈËÔ±²ÎÓë¸÷ÖÖ¼¼ÊõÊé¼®³ö°æ¡£
ͨ¹ý¸ÃÊé¼®£¬×÷Õß¿ÉÒԵõ½Èçϱ¨³ê£º
1¡¢·áºñµÄ¸å³ê¡£
2¡¢Êé¼®Öø×÷µÄÊðÃûȨ¡£
3¡¢¶Ô×÷ÕߺÍÊé½øÐÐÐû´«£¬Ìá¸ß×÷ÕßÔÚ¼¼ÊõȦ×ÓÀ ......
È磺
def aa(i):
print i
a=[1,2,3]
b=2
c=3
ÄÜʶ±ð³öÆðʼλdef aa(i):
ºÍ½áÊøλ" a=[1,2,3]"£¿
ÏñPython¶ÔÓï·¨ÕâôҪÇóÑϸñµÄÎÒ¾õµÃ¾Í²»ÒªÓÃÕýÔòÁË£¬Ð§Âʲ»¸ß¡£Ö±½ÓÓÃÅжϾͿÉÒÔÁË£¬Î ......
ʹÓÃxml.dom½âÎö¼¸Õ×µÄxmlÎļþ£¬·Ç³£»ºÂý£¬ÓÐÖÖ¼ÙËÀµÄ¸Ð¾õ¡£Ôõô½â¾ö£¿ÓÃÆäËû¿âÊÇ·ñ»áºÃЩ£¬ÔÝʱֻ֪µÀÕâ¸ö¿âµÄ¡£
Äã¿ÉÒÔÊÔÒ»ÏÂElementTree
pythonµÄ¹Ù·½Àý×Ó
import xml.parsers.expat
# 3 handler ......