代码之家  ›  专栏  ›  技术社区  ›  Berry Tsakala

在Windows(从python)中检索当前驱动器号[重复]

  •  2
  • Berry Tsakala  · 技术社区  · 15 年前

    可能重复:
    Is there a way to list all the available drive letters in python?

    如何在Windows中检索当前安装的驱动器列表,包括拇指驱动器和映射网络。

    我现在做的

        drives=[]
        for c in string.lowercase:
            if os.path.isdir(c+':'):
                drives.append(c+':')
    

    它看起来很难看,但完全不亲吻:)

    1 回复  |  直到 15 年前
        1
  •  3
  •   Sanjaya R    15 年前
    win32api.GetLogicalDriveStrings().split("\x00")