解决方法:看一下老外是怎么解决的:解决办法
部分代码:
def readonly_handler(func,path,execinfo):
os.chmod(path,128)
func(path);
def copyToTarget(oldPath,newPath):
global absPath;
tempNewPath = "";
tempOldPath = "";
print("sys's platform is ",sys.platform);
if(sys.platform == "win32"):
tempNewPath = absPath + "\\" + newPath;
tempOldPath = absPath + "\\" + oldPath;
print("tempOldPath is ",tempOldPath);
if(os.path.exists(tempNewPath)):
shutil.rmtree(tempNewPath,onerror=readonly_handler); # 删除目录树
os.mkdir(tempNewPath);
# os.chmod(tempNewPath,mode=0o007);
print("tempOldPath is ",tempOldPath);
# 开始copy文件
for root,dirs,files in os.walk(tempOldPath):