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

¹ØÓÚPythonµÄjoin£¨£©·½·¨ÎÊÌâ

´úÂëÈçÏ£º
import os
import time

source = [r'e:\python',r'e:\temp']
#print(source)
print('Ô´£º')
for spath in source:
    print(spath)
target_dir = r'e:\bak'
print('\nÄ¿µÄµØ£º')
print(target_dir)
target = time.strftime('%Y%m%d%H%M%S') + '.rar'
zip_command = 'rar a %s\%s %s' % (target_dir,target,' '.join(source))

if os.system(zip_command) == 0:
    print('Successful backup to',target)
else:
    print('Backup FAILED')

ÎÊÌ⣺
Çë½Ìһϣ¬' '.join(source)µÄ×÷ÓÃÊǽ«ÁбísourceÖеÄÏîĿת»»Îª×Ö·û´®£¬ÄÇôΪʲôҪÔÚÕâ¸ö·½·¨Ç°¼ÓÉÏ' '.£¿ÕâÊÇʲôÓÃ;£¿ÎªÊ²Ã´²»ÄÜÖ±½ÓʹÓÃjoin(source)£¿ÎÒÊdzõѧÕߣ¬Âé·³¸÷λ²»Áߴͽ̣¬Ð»Ð»£¡
ÒòΪËûÊÇstrµÄÒ»¸ö·½·¨£¬²»ÊÇͨÓú¯Êý¡£¼´Ê¹ÓиöͨÓú¯ÊýÒ²Ó¦¸ÃÏñjoin(source, sep)¶à¸ö·Ö¸ô·û²ÎÊý²Å»áÏ൱...

¶Ôà¸, strµÄÒ»¸ö·½·¨

>>> s=''
>>> dir(s)
.......'find', 'format', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', ...

ÄãÏëÖ±½ÓÓÃjoinÒ²¿ÉÒԵİ¡£¬Ã»ÎÊÌ⣺

import string
string.join(["aaaa", "bbb"])

»òÕߣº

from string


Ïà¹ØÎÊ´ð£º

eric4ÔõôÔËÐÐpython³ÌÐò£¿

pythonºÍpyqtÒÔ¼°Eric4¶¼ÒѾ­ÅäÖúÃÁË£¬´ò¿ªEric4д¸öpython³ÌÐò±ÈÈç¼òµ¥µÄ
print¡°hello£¬world¡±£¬Ôõô±àÒëÔËÐÐÁË£¬Start²Ëµ¥µÄËùÓÐÃüÁ³öÏÖºÍͼÖв¶àµÄ¶Ô»°¿ò£¬Ó¦µ±ÔõôÔËÐÐÁË£¿

Çó´ó¼ÒÖ¸½Ì

ûÓÐÈËÓà ......

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

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

JavaÓëPython»ìºÏµ÷ÓÃÇë½Ì

ÎÒÓÃpython¿ª·¢ÁËÒ»×éGUI½çÃ棬ÁíÍâÒ»¸öͬ־ÓÃjavaʵÏÖÁËÓ¦ÓÃÖ÷¿ò¼Ü£¬ÏÖÔÚÒª½«ÕâЩGUI½çÃ漯³Éµ½Ö÷¿ò¼ÜÀïÃæÈ¥¡£²»ÖªµÀÔÚjavaÀïÃæ¸ÃÈçºÎµ÷Ó㿼ò¶øÑÔÖ®£¬¾ÍÊÇjava´úÂëÀïÃæÈçºÎµ÷ÓÃÒ»¸öÍⲿµÄ.pyÎļþ¡£Çë¸ø³öÒ»¸ö¼òµ¥µ ......

Ë­ÄÜ°ïÎÒ·ÖÎöpython¹ú¼Ê»¯±¨´íÎÊÌâ

´íÎó´úÂëÈçÏ£º
<strong>exceptions.UnicodeEncodeError &lt;br /&gt; &amp;#39;ascii&amp;#39; codec can&amp;#39;t encode characters in position 0-5: ordinal not in range(128)& ......

¹ØÓÚpython ±Õ°üµÄÒ»¸öÎÊÌ⣨±Õ°üÓеãÄÑÀí½â£©

python ºËÐıà³Ì£¨µÚ¶þ°æ£© ÖÐ £¬11.8.4 ±Õ°üÓиöÀý×Ó

def counter(start_at=0):
count = [start_at]
def incr():
count[0] += 1
return count[0]
return incr

ÄѵÀÆäÖÐcount[] ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ