0

I what to know how to get a list of working drives in python(Windows)

import win32api

drives = win32api.GetLogicalDriveStrings()
drives = drives.split('\000')[:-1]
print drives

works but gets a list of all the posable drives i what a list of all the currently plugged in/working drives

  • 1
    Does this answer your question? [Is there a way to list all the available Windows' drives?](https://stackoverflow.com/questions/827371/is-there-a-way-to-list-all-the-available-windows-drives) – user_na Jun 20 '21 at 17:32
  • 2
    use this answer `available_drives = ['%s:' % d for d in string.ascii_uppercase if os.path.exists('%s:' % d)]`, you can also use your approach and filter for `os.path.exits(..)` – user_na Jun 20 '21 at 17:33

1 Answers1

0

Use this line of code

available_drives = ['%s:' % d for d in string.ascii_uppercase if os.path.exists('%s:' % d)]

You can also use your approach and filter for os.path.exits(..)

Kabilan Mohanraj
  • 1,856
  • 1
  • 7
  • 17