Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在windows中检索当前驱动器号(从python)_Python_Windows - Fatal编程技术网

在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")