File "G:/od15/调试/翻译文件更换/更新翻译po文件.py", line 42, in
shutil.copyfile(gxpath,dir_file_path)
File "E:\odsoft\python\lib\shutil.py", line 120, in copyfile
with open(src, 'rb') as fsrc:
PermissionError: [Errno 13] Permission denied: 'F:\\odoosoft\\odoo_15.0.20221230\\test'
出现以上错误,主要是copyfile()的参数为文件夹引起,更换成文件就可以了
有关copyfile()方法的要点。
代码:
rootPath = r"F:\odoosoft\odoo_15.0.20221230\addons"
gxpath = r'F:\odoosoft\odoo_15.0.20221230\test'
for dir_file in os.listdir(rootPath):
dir_file_path = os.path.join(rootPath, dir_file,'i18n','zh_CN.po')
# 删除i18n下所有文件
# delallfile(dir_file_path)
# print('原目录',dir_file_path)
# dirList.append(dir_file_path)
# mulu.append(dir_file)
copyfile = os.path.join(gxpath,dir_file,'i18n','zh_CN.po')
# print('dd',copyfile)
if os.path.isfile(copyfile):
print(copyfile)
print(dir_file_path)
shutil.copyfile(copyfile,dir_file_path)
print('更新成功')