我有一个问题,将2个文件夹与它的子目录组合,我有2个文件夹源。我将其命名为:test-2
和test-2
,这些文件夹的路径为output/test-2
和output/test-4
我将它与这一行结合起来:
merged_folder_path = 'merged/dir/output'
shutil.copy(result_1_path, merged_folder_path)
shutil.copy(result_2_path, merged_folder_path)
但是它出错:
Traceback (most recent call last):
File "jamu.py", line 769, in <module>
main(sys.argv)
File "jamu.py", line 757, in main
shutil.copy(result_1_path, merged_folder_path)
File "C:\Python27\lib\shutil.py", line 119, in copy
copyfile(src, dst)
File "C:\Python27\lib\shutil.py", line 82, in copyfile
with open(src, 'rb') as fsrc:
IOError: [Errno 13] Permission denied: 'output/test-2'
我的代码有问题吗?
答案 0 :(得分:0)
复制/移动/删除前检查烫发
import os
if os.access(merged_folder_path,os.W_OK):
shutil.copy(...,...)
答案 1 :(得分:0)
我遇到同样的问题here。
它对我有用, 感谢所有的答案。 apreciated it!