title: How to use win environment variable "pathlib" to save files?
body: <p>I'm trying to use win environment variable like <code>%userprofile%\desktop</code> with <code>pathlib</code> to safe files in different users PC.</p>
  
  <p>But I'm not able to make it work, it keep saving in on the running script dir.</p>
  
  <p><pre>
  import pathlib
  from datetime import datetime</p>
  
  <code>a = r'%userprofile%\desktop\test2'
  b = 'test'
  def path(path_name, f_name):
      date = datetime.now().strftime("%d%m-%H%M%S")
      file_name = f'{f_name}--{date}.xlsx'
      file_path = pathlib.Path(path_name).joinpath(file_name)
      file_dir = pathlib.Path(path_name)
      try:
          file_dir.mkdir(parents=True, exist_ok=True)
      except OSError as err:
          print(f"Can't create {file_dir}: {err}")
      return file_path
  
  path(a, b)
  </code></pre>