import os
import time
source=['/home/tudou/nihao']
target_dir='/home/tudou/nihao'
today=target_dir+os.sep+\
time.strftime('%Y%m%d')
now=time.strftime('%H%M%S')
target=today+os.sep+now+'.zip'
if not os.path.exists(today):
os.mkdir(today)
print('successful created directory',today)
zip_command='zip -r {0} {1}'.format(target,
' '.join(source))
print('zip command is')
print(zip_command)
print('Running :')
if os.system(zip_command)==0:
print('successful',target)
else :
print('Backup FAILED')
```
Python 制作简单压缩文件脚本
最新推荐文章于 2024-08-29 09:21:27 发布