1
import os
import shutil

dir_src='D:\\'
dir_dst='C:\\Windows\\System32\\oobe\\Info\\backgrounds\\'
src_file=os.path.join(dir_src,'background.jpg')
dst_file=os.path.join(dir_dst,'backgroundefault.jpg')
print(os.path.join(dir_dst,'backgroundefault.jpg'))
shutil.move(src_file,dst_file)

我一直在尝试将文件复制到C:\Windows\System32\oobe\Info\backgrounds但我收到此错误:

Traceback (most recent call last):
C:\Windows\System32\oobe\Info\backgrounds\backgroundefault.jpg
  File "C:\python\python36\lib\shutil.py", line 544, in move
    os.rename(src, real_dst)
PermissionError: [WinError 5] Access is denied: 'D:\\background.jpg' -> 'C:\\Windows\\System32\\oobe\\Info\\backgrounds\\backgroundefault.jpg'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/Harish/Downloads/demo (1).py", line 9, in <module>
    shutil.move(src_file,dst_file)
  File "C:\python\python36\lib\shutil.py", line 558, in move
    copy_function(src, real_dst)
  File "C:\python\python36\lib\shutil.py", line 257, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "C:\python\python36\lib\shutil.py", line 121, in copyfile
    with open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: 'C:\\Windows\\System32\\oobe\\Info\\backgrounds\\backgroundefault.jpg'

我该如何解决?

4

0 回答 0