os.homedir()


返回当前用户的主目录的字符串路径。

¥Returns the string path of the current user's home directory.

在 POSIX 上,它使用 $HOME 环境变量(如果已定义)。否则它使用 有效的 UID 来查找用户的主目录。

¥On POSIX, it uses the $HOME environment variable if defined. Otherwise it uses the effective UID to look up the user's home directory.

在 Windows 上,它使用 USERPROFILE 环境变量(如果已定义)。否则,它使用当前用户的配置文件目录的路径。

¥On Windows, it uses the USERPROFILE environment variable if defined. Otherwise it uses the path to the profile directory of the current user.