In Python, I understand that I can delete several files with the same name using the following command:
Can be removed from I really want to delete several directories with the same name, and if they are not empty, then I'm looking for something like Is there any way to do this with python? You have all the pieces: Shutil.rmtree ('/ path / to / dir') - and this command will remove the directory, even if the directory is not empty. On the other hand,
os.rmdir () needs to be empty.
shutil.rmtree ('directory _ *')
iterates ,
: shutil.rmtree (path) < P> This
OSError if a globbed path returns a file name, or for any other reason that
rmtree () may fail, you handle the error during the error view You can, once you decide how you want to handle errors, it is not understandable to add this error It comes, unless you do not know what you want to do with the error, so I have left to deal with the error.
No comments:
Post a Comment