[ACCEPTED]-Find System Hard Disk Drive from Python?-disk
This is how to return the letter of the System drive on a Win32 platform:
import os print os.getenv("SystemDrive")
The above snippet returns the system drive 1 letter. In my case ( and most cases on windows) C:
If you install the win32 extensions, the 4 following will get you the information you 3 want:
In : import win32api In : drives = win32api.GetLogicalDriveStrings() In : drives Out: 'C:\\\x00D:\\\x00E:\\\x00' In : drives.split('\x00') Out: ['C:\\', 'D:\\', 'E:\\', '']
Ignore the last item, due to a terminating 2 character in the string returned by win32's 1 GetLogicalDriveStrings function.
More Related questions