python获取windows下所有盘符
import ctypes
import os
lpBuffer = ctypes.create_string_buffer(78)
ctypes.windll.kernel32.GetLogicalDriveStringsA(ctypes.sizeof(lpBuffer), lpBuffer)
vol = lpBuffer.raw.split('\x00')
for i in vol:
print i
#遍历字母A到Z,忽略光驱的盘符
for i in range(65,91):
vol = chr(i) + ':'
if os.path.isdir(vol):
print vol
相关文章