[ACCEPTED]-Find System Hard Disk Drive from Python?-disk
Accepted answer
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 [82]: import win32api
In [83]: drives = win32api.GetLogicalDriveStrings()
In [84]: drives
Out[84]: 'C:\\\x00D:\\\x00E:\\\x00'
In [85]: drives.split('\x00')
Out[85]: ['C:\\', 'D:\\', 'E:\\', '']
Ignore the last item, due to a terminating 2 character in the string returned by win32's 1 GetLogicalDriveStrings function.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.