下面我写的用来获取逻辑磁盘大小的代码。
import wmi
import shutil
connection = wmi.connect_server(server="", user="", password="")
c = wmi.WMI(wmi=connection)
for logical_disk in partition.associators ("Win32_LogicalDiskToPartition"):
Disk_Caption = logical_disk.Caption
print(Disk_Caption)
total, used, free = shutil.disk_usage("\\")
print("Total: %d GB" % (total // (2 ** 30)))
print("Used: %d GB" % (used // (2 ** 30)))
print("Free: %d GB" % (free // (2 ** 30)))
我有C:和D :,但在C:和D:的输出中,都给出了C:本身的大小。
您能告诉我我在做什么错吗