Issue
How can I delete a file or folder in Python?
Solution
Use one of these methods:
pathlib.Path.unlink()
removes a file or symbolic link.pathlib.Path.rmdir()
removes an empty directory.shutil.rmtree()
deletes a directory and all its contents.
On Python 3.3 and below, you can use these methods instead of the pathlib
ones:
os.remove()
removes a file.os.unlink()
removes a symbolic link.os.rmdir()
removes an empty directory.
Answered By - RichieHindle
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.