import os target_dir = 'xxx' if not os.path.exists(target_dir): os.mkdir(target_dir)