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.】