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 !