- import ctypes
- lpBuffer = ctypes.create_string_buffer(78)
- ctypes.windll.kernel32.GetLogicalDriveStringsA(ctypes.sizeof(lpBuffer), lpBuffer)
- vol = lpBuffer.raw.split('\x00')
- for i in vol:
- if i:
- print i
复制代码 另外一个思路是遍历字母A到Z,但是光驱的盘符被忽略了,望大湿指点:- import os
- for i in range(65,91):
- vol = chr(i) + ':'
- if os.path.isdir(vol):
- print vol
复制代码
|