# How to delete a file using Python?

PythonServer Side ProgrammingProgramming

#### Beyond Basic Programming - Intermediate Python

Most Popular

36 Lectures 3 hours

#### Practical Machine Learning using Python

Best Seller

91 Lectures 23.5 hours

#### Practical Data Science using Python

22 Lectures 6 hours

You can delete a single file or a single empty folder with functions in the os module. For example, if you want to delete a file my_file.txt,

>>> import os
>>> os.remove('my_file.txt')

The argument to os.remove must be absolute or relative path.

Updated on 01-Oct-2019 11:54:30