Python Os.remove Fails To Remove
I want to remove files as follows: path = 'username/hw/01/' file_list = ['main.cc', 'makefile'] files = os.listdir(path) del_files = list(set(files) - set(file_list)) for del_file
Solution 1:
You might need to use os.remove(os.path.join(path, del_file))
instead of os.remove(path + del_file)
if path doesn't end with a path separator. Docs: os.path.join()
Post a Comment for "Python Os.remove Fails To Remove"