file_util_3.py 277 B

12345678
  1. def write_file(file_path, file_content):
  2. if file_path.find('/') != -1:
  3. father_dir = '/'.join(file_path.split('/')[0:-1])
  4. if not os.path.exists(father_dir):
  5. os.makedirs(father_dir)
  6. file_object = open(file_path, 'w')
  7. file_object.write(file_content)
  8. file_object.close()