Getting short path in python

前端 未结 2 664
孤街浪徒
孤街浪徒 2021-01-19 06:51

How do I obtain the short path of a file in Windows using python ?

I am using the following code ,

#!/usr/bin/python
import os
import sys
fileList =          


        
相关标签:
2条回答
  • 2021-01-19 07:23
    import win32api
    long_file_name='C:\Program Files\I am a file'
    short_file_name=win32api.GetShortPathName(long_file_name)
    
    0 讨论(0)
  • 2021-01-19 07:29

    I guess you are looking for this:

    http://docs.activestate.com/activepython/2.5/pywin32/win32api__GetShortPathName_meth.html

    Although you will need the win32api module for this.

    Also see this link: http://mail.python.org/pipermail/python-win32/2006-May/004697.html

    0 讨论(0)
提交回复
热议问题