Home > Article > Backend Development > Python sharing of various handling methods for failed file deletion
The following will share with you an article on how to deal with various failed file deletions in python. It has a very good reference value and I hope it will be helpful to everyone. Let’s take a look together
Calling various operations to delete files provided by python failed
The return value is 5, access is denied, but it has been confirmed multiple times that the file has not been opened, and the file is from a zip After the package was decompressed, there were no operations such as opening, reading or writing.
Finally, the forced deletion command of Windows was called to solve the problem
try: #shutil.rmtree(UPDATE_DIR_STR) #this maybe can't delete some files by error 5 os.system("rd/s/q 目录名") except Exception, e: pass print e
The above is the detailed content of Python sharing of various handling methods for failed file deletion. For more information, please follow other related articles on the PHP Chinese website!