You could use the path.exists() function:
from os import path
path.exists("C:/")
If you want to test only for root directory of a drive ("C:/" and not "C:/File/File2/") you could check that by mesuring the lenght of the path:
def is_drive(path):
if len(path) <= 3 and os.path.exists(path):
return True
return False
This method will return if drive exists. I hope this helps, it really depends on what you want to use this function for.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…