code: def _write_export(export, file_obj=None):
      
  
      if file_obj is None:
          return export
  
      if hasattr(file_obj, 'write'):
          out_file = file_obj
      else:
          out_file = open(file_obj, 'wb')
      try:
          out_file.write(export)
      except TypeError:
          out_file.write(export.encode('utf-8'))
  
      out_file.close()
  
      return export
docs: Write a string to a file.
      If file_obj isn't specified, return the string
  
      Parameters
      ---------
      export: a string of the export data
      file_obj: a file-like object or a filename