pythonpython-3.xpython-2.7movefile

Move a file with Python


I want to move a file and I'm having the following bug:

Traceback (most recent call last):
File "G:\Programming\Hack\scripts\# cut file.py", line 4, in <module>
shutil.move(src, dst)
File "C:\Program Files 1\Python2\lib\shutil.py", line 316, in move
copy2(src, real_dst)
File "C:\Program Files 1\Python2\lib\shutil.py", line 144, in copy2
copyfile(src, dst)
File "C:\Program Files 1\Python2\lib\shutil.py", line 97, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: 'E:\\windows.information.exe'

my script:

import shutil
src = "C:\\Users\\Michael\\Desktop\\windows.information.exe"
dst = "E:\\"
shutil.move(src, dst)

My main problem:

IOError: [Errno 13] Permission denied: 'E:\\windows.information.exe

Solution

  • in fact,this error occurred by permission. in c://Users ,need adminster authority to do it . you should use shutil.copy(src,dst) copy file and authority