在windows中检索当前驱动器号(从python)
可能重复:在windows中检索当前驱动器号(从python),python,windows,Python,Windows,可能重复: 如何在Windows中检索当前安装的驱动器列表,包括Thumb驱动器和映射网络 我现在有 drives=[] for c in string.lowercase: if os.path.isdir(c+':'): drives.append(c+':') 驱动器=[] 对于string.lowercase格式的c: 如果os.path.isdir(c+':'): 驱动器。追加(c+“:”) 这看起来很难看,但完全是防吻的:)重复:下面
如何在Windows中检索当前安装的驱动器列表,包括Thumb驱动器和映射网络 我现在有 drives=[] for c in string.lowercase: if os.path.isdir(c+':'): drives.append(c+':') 驱动器=[] 对于string.lowercase格式的c: 如果os.path.isdir(c+':'): 驱动器。追加(c+“:”)
这看起来很难看,但完全是防吻的:)重复:下面是一个基于Sanjaya回答的完整工作示例:
导入win32api def是否存在驱动器(字母):返回(win32api.GetLogicalDriveStrings()中的字母。拆分(“\x00”))打印是否存在驱动器(“p:\”
win32api.GetLogicalDriveStrings().split("\x00")