I'm trying to use win environment variable like %userprofile%\desktop
with pathlib
to safe files in different users PC.
But I'm not able to make it work, it keep saving in on the running script dir.
import pathlib
from datetime import datetimea = 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_pathpath(a, b)