def write_file_not_cover(file_path, file_content): father_dir = '/'.join(file_path.split('/')[0:-1]) if not os.path.exists(father_dir): os.makedirs(father_dir) file_object = open(file_path, 'a') file_object.write(file_content) file_object.close()