So I have a python program that ends up leaving a .dat file from the shelve function behind after execution. I would like my program to delete or clear that file once it is done. My textbook only mentions how to create a .dat file but not how to clear it. Any good commands out there to take care of this? I don’t need the .dat file again after my program runs to completion.
So I have a python program that ends up leaving a .dat file from
Share
This is easy:
runs
os.remove( path_to_file )when the Python interpreter exists in a normal (not killed/crashed) way. But you need to make sure the file is closed by then.