2009-06-05 13 views
2

可能性の重複:
Is there a way to list all the available drive letters in python?取得現在のドライブ文字

のWindows税込で現在マウントされたドライブの一覧を取得する方法は何。 Thumbドライブ、およびマップされたネットワーク

私は現在行う醜いに見えますが、完全に証明KISS :)です

 
    drives=[] 
    for c in string.lowercase: 
     if os.path.isdir(c+':'): 
      drives.append(c+':') 

+0

重複:http://stackoverflow.com/questions/827371/is-there-a -wayツーリストすべて利用可能なドライブ・レター・イン・パイソン –

答えて

3
win32api.GetLogicalDriveStrings().split("\x00") 
+0

ここサンジャヤの回答に基づいて完全な作業例です: '輸入のWin32API はデフ(手紙を)does_drive_exist:WIN32APIで リターン(手紙.GetLogical DriveStrings()。split( "\ x00")) print does_drive_exist( "P:\\") ' –

関連する問題