I need to find the home directory path of the logged in user
What I'm using on Linux is
os.getenv("HOME")
I can't do this on Windows.
Is there a function that can use both Windows and Linux?
This feature is provided by os.path.expanduser(path).
It works on Windows and Linux You can use it as below.
from os.path import expanduser
home = expanduser("~")
#or
home = expanduser ("~Demi") #UserName
© 2024 OneMinuteCode. All rights reserved.