import os
import time
source = ['D:\\test1']
target_dir = 'D:\\test2'
target = target_dir + os.sep + time.strftime('%Y%m%d%H%M%S') + '.zip'
if not os.path.exists(target_dir):
os.mkdir(target_dir)
zip_command = 'zip -r {} {}'.format(target, ' '.join(source)) #join是字符串的一个方法,用句号前面的字符链接source中参数。join中只能有一个对象,一个list,tuple等
print('zip command is')
print(zip_command)
if os.system(zip_command) == 0:
print('cg')
else:
print('sb')
join
最新推荐文章于 2023-03-16 22:16:34 发布