#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2022/9/9 0:04 # @Author : old tom # @File : fu_sys.py # @Project : Futool # @Desc : 用于获取当前系统信息,内存及硬盘信息获取请使用psutil import os import platform import getpass def is_windows(): """ 是否windows :return: """ return 'Windows' == platform.system() def is_linux(): """ 是否linux :return: """ return 'Linux' == platform.system() def is_unix(): """ 是否unix :return: """ return 'Unix' == platform.system() def os_name(): """ 操作系统名称 :return: """ return platform.platform() def host_name(): """ 获取主机名 :return: """ return platform.node() def sys_user(): """ 系统用户 :return: """ return getpass.getuser() def sys_user_dir(): """ 当前用户目录 :return: """ return os.path.expanduser('~') class CpuInfo(object): @staticmethod def cpu_architecture(): """ CPU架构,AMD64,i386 :return: """ return platform.machine() @staticmethod def cpu_count(): """ CPU核数 :return: """ return os.cpu_count()