Home  >  Article  >  Backend Development  >  Python sharing of various handling methods for failed file deletion

Python sharing of various handling methods for failed file deletion

不言
不言Original
2018-04-24 11:53:252419browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn