This question already has an answer here:
(这个问题已经在这里有了答案:)
- How to find the real user home directory using python?9 answers
(9个答案)
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:(目前,我一直在Linux上使用以下命令:)
os.getenv("HOME")
However, this does not work on Windows.
(但是,这在Windows上不起作用。)
What is the correct cross-platform way to do this?(正确的跨平台方法是什么?)
ask by Nathan Osman translate from so