备份文件中所存路径中的文件
<span style="font-size:18px;">#backup.py
import os
import time
source = [];
f=open('lb.txt','r')
while True:
line=f.readline()
if len(line)==0:
break
if line[-1] == '\n':
line = line[:-1]
source.append(line)
f.close()
#source=[r'F:\Python\finally.py',r'D:\LDJ\LDJ\Launch.ini',r'F:\Python\dir.py']
target_dir=r'F:\Python\backup'
target=target_dir + time.strftime('%Y%m%d%H%M%S')+".rar"
zip_command="rar a %s %s"%(target, ' '.join(source))
if (os.system(zip_command)==0):
print ('Successful backup to',target)
else:
print ('backup FAIlED')</span>
摘自weishanshan00的专栏
补充:Web开发 , Python ,