Wednesday 17 June 2020

How to remove and create folder at the same time in python?

import os
opath = 'output/images'
if os.path.exists(opath):
    shutil.rmtree(opath)  # delete output folder
os.makedirs(opath)  # make new output folder

No comments:

Post a Comment