可能重复:
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+':')
看起来难看,但完全是KISS证明:)
可能重复:
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+':')
看起来难看,但完全是KISS证明:)
win32api.GetLogicalDriveStrings().split("\x00")
这是一个基于Sanjaya的回答的完整工作示例: 'import win32api def does_drive_exist(letter): return(letter in win32api .GetLogical DriveStrings()。split(“\ x00”)) print does_drive_exist(“P:\\”)' – 2013-03-24 18:51:11
重复:http://stackoverflow.com/questions/827371/is-there-a Python- – 2009-06-05 17:02:37