Python 2: Get network share path from drive letter
问题 If I use the following to get the list of all connected drives: available_drives = ['%s:' % d for d in string.ascii_uppercase if os.path.exists('%s:' % d)] How do I get the UNC path of the connected drives? os.path just returns z:\ instead of \share\that\was\mapped\to\z 回答1: Use win32wnet from pywin32 to convert your drive letters. For example: import win32wnet import sys print(win32wnet.WNetGetUniversalName(sys.argv[1], 1)) This gives me something like this when I run it: C:\test>python get