docs: def write_file(dat, pth, append=False):
      """
          将 dat 内容写入 pth 中, 如果写入成功, 返回为空, 否则返回失败信息
  
      :type append: ``bool``
      :param append: 写入模式
      :type append: ``bool``
      :param dat: 待写入内容
      :type dat: ``str``
      :param pth:
      :type pth: ``str``
      :return:
      :rtype:
      """
      err = None
  
      _d, _nm = os.path.split(pth)
      if _d and not os.path.exists(_d):
          os.makedirs(_d)
  
      try:
          mode = 'ab' if append else 'wb'
  
          with open(pth, mode) as _fp:
              dat = to_bytes(dat)
              _fp.write(dat)
      except Exception as _err:
          err = _err
      return err