Skip to content

How to Delete a File in Python

Last updated on August 8, 2022

In this tutorial, you will learn how to delete a file using the Python programing language. Deleting files using Python is very simple. You can delete files using the os.remove() method. You can delete a file using both relative path and absolute path. Below is the example code.

Remove file with relative path

import os

# removing a file with relative path

Remove file with absolute path

import os

# remove file with absolute path

Comments are closed, but trackbacks and pingbacks are open.