os.path.expanduser(path)
On Unix and Windows, return the argument with an initial component of ~ or ~user replaced by that user‘s home directory.
[..]
On Windows, HOME and USERPROFILE will be used if set, otherwise a combination of HOMEPATH and HOMEDRIVE will be used. An initial ~user
is handled by stripping the last directory component from the created
user path derived above.
If the expansion fails or if the path does not begin with a tilde, the path is returned unchanged.