1import os
2filePath = '/home/somedir/Documents/python/logs'
3
4if os.path.exists(filePath):
5 os.remove(filePath)
6else:
7 print("Can not delete the file as it doesn't exists")
1import os
2os.remove(fn) if os.path.exists(fn) else None #here fn - filename or filepath