|
| 1 | +import platform |
| 2 | +import os |
| 3 | +import sys |
| 4 | +import psutil |
| 5 | +print('='*50) |
| 6 | + |
| 7 | +# 显示系统信息 |
| 8 | +print('hello world') |
| 9 | +print('-'*50) |
| 10 | +print('系统信息') |
| 11 | +print("操作系统:", platform.system()) |
| 12 | +print("架构:", platform.machine()) |
| 13 | +print("版本:", platform.version()) |
| 14 | +print("平台:", platform.platform()) |
| 15 | + |
| 16 | +# 显示硬件信息 |
| 17 | +print('-'*50) |
| 18 | +print('CPU 信息') |
| 19 | +print(f"CPU 核心数: {psutil.cpu_count(logical=False)}") |
| 20 | +print(f"逻辑处理器数: {psutil.cpu_count(logical=True)}") |
| 21 | +print("处理器信息:", platform.processor()) |
| 22 | +cpu_times = psutil.cpu_times() |
| 23 | +print(f"用户时间: {cpu_times.user}") |
| 24 | +print(f"系统时间: {cpu_times.system}") |
| 25 | +print(f"空闲时间: {cpu_times.idle}") |
| 26 | + |
| 27 | +memory_info = psutil.virtual_memory() |
| 28 | + |
| 29 | +print('-'*50) |
| 30 | +print('内存 信息') |
| 31 | +print(f"总内存: {memory_info.total / (1024 ** 3)} GB") |
| 32 | +print(f"空闲内存: {memory_info.free / (1024 ** 3)} GB") |
| 33 | +print(f"已用内存: {memory_info.used / (1024 ** 3)} GB") |
| 34 | +print(f"可用内存: {memory_info.available / (1024 ** 3)} GB") |
| 35 | + |
| 36 | +# 获取内存详细信息 |
| 37 | +print('-'*50) |
| 38 | +print('交换内存 信息') |
| 39 | +swap_memory = psutil.swap_memory() |
| 40 | +print(f"交换内存总量: {swap_memory.total / (1024 ** 3)} GB") |
| 41 | +print(f"已用交换内存: {swap_memory.used / (1024 ** 3)} GB") |
| 42 | +print(f"可用交换内存: {swap_memory.free / (1024 ** 3)} GB") |
| 43 | + |
| 44 | +print("系统编码:", sys.getdefaultencoding()) |
| 45 | +print("文件系统编码:", sys.getfilesystemencoding()) |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +# 显示Python信息 |
| 50 | +print("Python版本:", sys.version) |
| 51 | +print("Python路径:", sys.executable) |
| 52 | +print("当前工作目录:", os.getcwd()) |
| 53 | + |
| 54 | + |
| 55 | +print('='*50) |
0 commit comments