Python - How to get the names of the drivers C: D: F: I:

1
  

I am developing GUI in Python 3.6 using TKinter . I came to an impasse where I have to get the installed driver letters and their names in the same way they appear in Windows Explorer . See attached picture.

With the code below I can get the letters of the drivers, but not the names.

drives = win32api.GetLogicalDriveStrings()
drives = drives.split('
drives = win32api.GetLogicalDriveStrings()
drives = drives.split('%pre%0')[:-1]
0')[:-1]

Has anyone ever had this problem?

    
asked by anonymous 04.05.2017 / 16:19

1 answer

2

As Anderson suggested, use win32api.GetVolumeInformation , just iterate with for , like this:

import win32api

drives = win32api.GetLogicalDriveStrings()
drives = drives.split('
import win32api

drives = win32api.GetLogicalDriveStrings()
drives = drives.split('%pre%0')

for drive in drives:
    try:
        print(win32api.GetVolumeInformation(drive.strip()))
    except:
        pass
0') for drive in drives: try: print(win32api.GetVolumeInformation(drive.strip())) except: pass
    
04.05.2017 / 17:16