在本书P14页当中的复制文件shutil.copy("oldfile", "newfile")进行第二个方案,newfile可以是目标目录时无法成功进行,不知何解
代码如下:shutil.copy(r".\Richard_exercise", r"F:\Computer\Compute;r_Python\Exercise")
报错如下:Traceback (most recent call last):
File "E:\Anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 2910, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 1, in
runfile('F:/Computer/Computer_Python/File_operation_exercise/File_operation_exercise.py', wdir='F:/Computer/Computer_Python/File_operation_exercise')
File "E:\PyCharm Community Edition 2018.2.4\helpers\pydev_pydev_bundle\pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "E:\PyCharm Community Edition 2018.2.4\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "F:/Computer/Computer_Python/File_operation_exercise/File_operation_exercise.py", line 58, in
shutil.copy(r".\Richard_exercise", r"F:\Computer\Compute;r_Python\Exercise")
File "E:\Anaconda\lib\shutil.py", line 241, in copy
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "E:\Anaconda\lib\shutil.py", line 120, in copyfile
with open(src, 'rb') as fsrc:
PermissionError: [Errno 13] Permission denied: '.\Richard_exercise'
在本书P14页当中的复制文件shutil.copy("oldfile", "newfile")进行第二个方案,newfile可以是目标目录时无法成功进行,不知何解 代码如下:shutil.copy(r".\Richard_exercise", r"F:\Computer\Compute;r_Python\Exercise") 报错如下:Traceback (most recent call last): File "E:\Anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 2910, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in
runfile('F:/Computer/Computer_Python/File_operation_exercise/File_operation_exercise.py', wdir='F:/Computer/Computer_Python/File_operation_exercise')
File "E:\PyCharm Community Edition 2018.2.4\helpers\pydev_pydev_bundle\pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "E:\PyCharm Community Edition 2018.2.4\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "F:/Computer/Computer_Python/File_operation_exercise/File_operation_exercise.py", line 58, in
shutil.copy(r".\Richard_exercise", r"F:\Computer\Compute;r_Python\Exercise")
File "E:\Anaconda\lib\shutil.py", line 241, in copy
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "E:\Anaconda\lib\shutil.py", line 120, in copyfile
with open(src, 'rb') as fsrc:
PermissionError: [Errno 13] Permission denied: '.\Richard_exercise'