Python os.remove()

Viewed 219

I have a more general question about the os.remove() -function. When I use it to delete a file, does Python delete it entirely from the computer or does Python move it to another folder similar to the trash on mac?

2 Answers

os.remove() doesn't send things to Trash. It just deletes them.

You can check it yourself very easily:

import os

file = 'file.txt'
location = "/home/User/Documents"
path = os.path.join(location, file)
os.remove(path)
print("%s has been removed successfully" % file)
Related