retrieving current drive letters in windows (from python) [duplicate]

Possible Duplicate:
Is there a way to list all the available drive letters in python?

What's the way to retrieve currently mounted drive list in Windows incl. Thumb drives, and mapped networks.

i currently do

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

which looks ugly, but is completely KISS proof :)


Asked by: Kristian999 | Posted: 06-12-2021






Answer 1

win32api.GetLogicalDriveStrings().split("\x00")

Answered by: Edward204 | Posted: 07-01-2022



Similar questions

retrieving current URL from FireFox with python

I want to know what is the current url of active tab in running firefox instance from python module. Does FireFox have any API for this and does python know to work with it?


python - Retrieving the name of the current test case running

I've seen how to retrieve the name of the current test case running for Python Selenium Unittest. unittest.TestCase.id() How to achieve this using Webdriver Py.test framework? I'm not using unittest framework so my test looks something like this: from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from ...


retrieving current URL from FireFox with python

I want to know what is the current url of active tab in running firefox instance from python module. Does FireFox have any API for this and does python know to work with it?


Retrieving network mask in Python

How would one go about retrieving a network device's netmask (In Linux preferably, but if it's cross-platform then cool)? I know how in C on Linux but I can't find a way in Python -- minus ctypes perhaps. That or parsing ifconfig. Any other way? ioctl(socknr, SIOCGIFNETMASK, &ifreq) // C version


python - Retrieving a tuple from a collection of tuples based on a contained value

I have a data structure which is a collection of tuples like this: things = ( (123, 1, "Floogle"), (154, 33, "Blurgle"), (156, 55, "Blarg") ) The first and third elements are each unique to the collection. What I want to do is retrieve a specific tuple by referring to the third value, eg: >>> my_thing = things.get( value(3) == "Blurgle" ) (154, 33, "Blurgle...


Retrieving all Cookies in Python

How do I read back all of the cookies in Python without knowing their names?


python - Retrieving Raw_Input from a system ran script

I'm using the OS.System command to call a python script. example: OS.System("call jython script.py") In the script I'm calling, the following command is present: x = raw_input("Waiting for input") If I run script.py from the command line I can input data no problem, if I run it via the automated approach I get an EOFError. I've read in the past th...


c# - Retrieving the return value of a Python script

I have an external C# program which executes a Python script using the Process class. My script returns a numerical code and I want to retrieve it from my C# program. Is this possible? The problem is, I'm getting the return code of python.exe instead of the code returned from my script. (For example, 3.)


python function for retrieving key and encryption

M2Crypto package is not showing the 'recipient_public_key.pem' file at linux terminal. How do I get/connect with recipient public key. Exactly, I need to check how can I open this file through linux commands. import M2Crypto def encrypt(): recip = M2Crypto.RSA.load_pub_key(open('recipient_public_key.pem','rb').read()) print recip; plaintext = whatever i need to encrypt msg = ...


utf 8 - Retrieving and displaying UTF-8 from a .CSV in Python

Basically I have been having real fun with this today. I have this data file called test.csv which is encoded as UTF-8: "Nguyễn", 0.500 "Trần", 0.250 "Lê", 0.250 Now I am attempting to read it with this code and it displays all funny like this: Trần Now I have gone through all the Python docs for 2.6 which is the one I use and I can't get the wrapper to work along with all the ideas on the interne...


Retrieving doubly raised exceptions original stack trace in python

If I have a scenario where an exception is raised, caught, then raised again inside the except: block, is there a way to capture the initial stack frame from which it was raised? The stack-trace that gets printed as python exits describes the place where the exception is raised a second time. Is there a way to raise the exception such that the stack frame that the exception was originally thrown is shown?


email - Python: Retrieving only POP3 message text, no headers

I'm trying to make a Python program that retrieves only the body text of an email without passing headers or any other parameters. I'm not sure how to go about this. The goal is to be able to send basic commands to a program via message text. What I have now is this: import poplib host = "pop.gmail.com" mail = poplib.POP3_SSL(host) print mail.getwelcome() print mail.user("user") print mail....






Still can't find your answer? Check out these communities...



PySlackers | Full Stack Python | NHS Python | Pythonist Cafe | Hacker Earth | Discord Python



top