hutool.core.util.system

系统属性工具类

Module Contents

Classes

SystemUtil

系统属性工具类,提供环境变量和系统信息获取功能。

API

class hutool.core.util.system.SystemUtil

系统属性工具类,提供环境变量和系统信息获取功能。

static get(name: str, default: Optional[str] = None) Optional[str]

获取系统环境变量。

参数:
  • name – 环境变量名

  • default – 不存在时的默认值,默认 None

返回:

环境变量值或默认值

static get_all() dict

获取所有系统环境变量。

返回:

环境变量字典

static get_os_name() str

获取操作系统名称。

返回:

操作系统名称,如 "Windows""Linux""Darwin"

static get_os_arch() str

获取操作系统架构。

返回:

架构字符串,如 "x86_64""AMD64"

static get_user_dir() str

获取用户当前工作目录。

返回:

当前工作目录的绝对路径

static get_user_home() str

获取用户主目录。

返回:

用户主目录路径

static get_tmp_dir() str

获取系统临时目录。

返回:

临时目录路径

static get_file_separator() str

获取文件路径分隔符。

返回:

路径分隔符,Windows 为 \,Unix 为 /

static get_line_separator() str

获取行分隔符。

返回:

行分隔符,Windows 为 \r\n,Unix 为 \n

static is_windows() bool

判断当前系统是否为 Windows。

返回:

是否为 Windows 系统