Python sharing of various handling methods for failed file deletion

不言
Release: 2018-04-24 11:53:25
Original
2418 people have browsed it

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
Copy after login


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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!