code: def write_file(file_path, txt, **kws):
      
      if not os.path.exists(file_path):
          upDir = os.path.dirname(file_path)
          if not os.path.isdir(upDir):
              os.makedirs(upDir)
  
      kw = {"mode":"w", "encoding":"utf-8"}
      if kws:
          for k,v in kws.items():
              kw[k] = v
      with open(file_path, **kw) as afile:
          afile.write(txt)
docs: 将文本内容写入文件。
  
      :param str file_path: 文件路径。
      :param str txt: 待写入的文件内容。