索尼与三星 2016-10-25 09:11 采纳率: 33.3%
浏览 1070

Python中拷贝文件不能创建输出文件

我在python简明教程中看到了拷贝文件:
我想把D:\home 和D:\new 下的.zip文件拷贝到D:下

import os
import time

source = [r'D:\home', r'D:\new']

target_dir = r'D:'

target = target_dir + time.strftime('%Y%m%d%H%M%S') + '.zip'

zip_command = "zip -qr '%s' %s" % (target, ' '.join(source))


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

结果报错:

Could not create output file (was replacing the original zip file)

请问这是怎么回事?
谢谢!

  • 写回答

2条回答 默认 最新

  • devmiao 2016-10-25 09:45
    关注
    评论

报告相同问题?