home-directory

What is the correct cross-platform way to get the home directory in Python?

What is a cross-platform way to get the home directory? Question: 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 ? Asked By: Nathan …

Total answers: 5

How to find the real user home directory using python?

How to find the real user home directory using python? Question: I see that if we change the HOME (linux) or USERPROFILE (windows) environmental variable and run a python script, it returns the new value as the user home when I try os.environ[‘HOME’] os.exp Is there any way to find the real user home directory …

Total answers: 9