建模程序 多个定时程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

15 lines
562 B

import psutil
# 获取硬盘分区列表
partitions = psutil.disk_partitions()
for partition in partitions:
print("分区信息",partition)
# 获取指定分区(比如'C:')的使用情况
if partition.mountpoint == 'G:\\': # 更改为您要检测的硬盘分区
usage = psutil.disk_usage(partition.mountpoint)
print(f"Total: {usage.total / (1024**3):.2f} GB")
print(f"Used: {usage.used / (1024**3):.2f} GB")
print(f"Free: {usage.free / (1024**3):.2f} GB")
print(f"Percentage: {usage.percent}%")