程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

When using the shutil module in Python, there is a permissionerror: [errno 13] permission denied error. How to solve it

編輯:Python

I'm the son of Science .

stay python Of shutil Module , For the first time shutil.copyfile(src,dst), It's easy to come up with ”PermissionError: [Errno 13] Permission denied“ Such a mistake , The specific code is as follows :

 

This line of code , The intention is to ‘ Download instructions .htm’ This file , Copied to the python In the currently running folder , But there was ‘PermissionError: [Errno 13] Permission denied’ Such a mistake . What is the reason for this result ?

 

Navigate to the wrong line , We found the problem : original shulte.coptfile(src,dst) This function , Yes, it will src、dst Operate directly as a file , So this requires src It has to be 、 Specific documents ,dst This variable needs to be a specific file ( It doesn't matter if the file doesn't exist , Just be famous ), Otherwise, this function will make an error .

I understand that , Next, just put src Change the variable to specific 、 Documents that exist ,dst Just have a file name , As shown below :

 

I'm the son of Science , Pay attention to me ! Learn together python, Do big data analysis 、 Game development , Study artificial intelligence ! If you feel useful , Welcome to press one button three times ! Everyone's support , It's the driving force for me to move forward !


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved