More Than Five
More Than Five

Reputation: 10429

Get the system root dirs?

I know there a lot of path API's in python, but I am looking for an API that will give me the very root directories of the system the script is executing in. Not root directories of the script itself but the actual system.

So, for a standard windows laptop I would expect at least

C:\

And then if I have something connnected, like an android device via USB something for that to.

Any tips? Note my particular interest here is for windows.

Thanks.

Upvotes: 0

Views: 1963

Answers (1)

Zero0evolution
Zero0evolution

Reputation: 81

Try this code:

>>> import os
>>> os.path.expandvars("%SystemRoot%")
'C:\\Windows'

Upvotes: 1

Related Questions