How to delete a file or folder in Python?
转载于:https://stackoverflow.com/questions/6996603/delete-a-file-or-folder
How to delete a file or folder in Python?
转载于:https://stackoverflow.com/questions/6996603/delete-a-file-or-folder
os.remove()
removes a file.
os.rmdir()
removes an empty directory.
shutil.rmtree()
deletes a directory and all its contents.
pathlib.Path.unlink()
removes the file or symbolic link.
pathlib.Path.rmdir()
removes the empty directory.