This question already has an answer here:
I need to get the location of the home directory of the current logged-on user. Currently, I've been using the following on Linux:
os.getenv("HOME")
However, this does not work on Windows. What is the correct cross-platform way to do this?
You want to use os.path.expanduser. This will ensure it works on all platforms
If you're on Python 3.5+ you can use pathlib.Path.home():