import platform
import subprocessdef get_gpu_info():system = platform.system()try:if system == "Windows":# Windows: 使用 wmic 命令output = subprocess.check_output("wmic path win32_VideoController get Name", shell=True).decode()gpu_info = [line.strip() for line in output.split("\n") if line.strip() and "Name" not in line]print("显卡信息:")for info in gpu_info:print(f"- {info}")elif system == "Linux":# Linux: 使用 lspci 命令output = subprocess.check_output("lspci | grep -i 'vga\|3d\|display'", shell=True).decode()print("显卡信息:")print(output.strip())elif system == "Darwin": # macOS# macOS: 使用 system_profiler 命令output = subprocess.check_output("system_profiler SPDisplaysDataType | grep 'Chipset Model'",shell=True).decode()print("显卡信息:")print(output.strip())else:print(f"不支持的操作系统: {system}")except Exception as e:print(f"获取显卡信息失败: {e}")if __name__ == "__main__":get_gpu_info()