Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pyhon爬虫开发项目与实践当中的bug #117

Open
RichardlauCx opened this issue Jul 2, 2019 · 1 comment
Open

Pyhon爬虫开发项目与实践当中的bug #117

RichardlauCx opened this issue Jul 2, 2019 · 1 comment

Comments

@RichardlauCx
Copy link

在本书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'

@RichardlauCx
Copy link
Author

找到问题原因啦,是因为shutil.copy()中的newfile 强调的一直都是文件,所以改为shutil.copy(r".\Richard_exercise.txt", r"F:\Computer\Computer_Python\Exercise")之后就可以了,希望大家不要犯这样的语法错误,领悟透彻了再下手

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant