import os, shutil
## Remove a file or directory.
def remove(path) :
retval = False
try:
if os.path.exists(path):
if os.path.isdir(path):
shutil.rmtree(path, ignore_errors = True)
retval = True
elif os.path.isfile(path):
os.remove(path)
retval = True
else:
retval = True
except OSError as e:
print(e)
except Exception as e:
print(e)
return retval
沒有留言:
張貼留言