I'm looking for a function to erase all the contents in the folder
I looked it up, but os.rmdir() can only erase empty directories (although I can recursively call and create them myself).
I want to know if there's a function that erases the contents
file python local delete-dictionary
The usage is approximately as follows.
import shutil
shutil.rmtree('/path/to/folder')
shutil.rmtree (path, ignore_errors=False, on error=None)
Delete an entire directory tree; path must point to a directory (but not a symbolic link to a directory). If ignore_errors is true, errors resulting from failed removals will be ignored; if false or omitted, such errors are handled by calling a handler specified by onerror or, if that is omitted, they raise an exception.
Clears the entire directory tree. The path must be a directory (not included for symbolic links pointing to the directory). If ignore_errors
is true, the error is ignored even if the uninstallation fails.
© 2024 OneMinuteCode. All rights reserved.