【问题标题】:Getting short path in python在python中获取短路径
【发布时间】:2011-08-30 10:50:17
【问题描述】:

如何在 Windows 中使用 python 获取文件的短路径?

我正在使用以下代码,

#!/usr/bin/python
import os
import sys
fileList = []
rootdir = sys.argv[1]
for root, subFolders, files in os.walk(rootdir):
    for file in files:
        fileList.append(os.path.join(root,file))
for File in fileList:
    print File

【问题讨论】:

    标签: python windows path filenames


    【解决方案1】:
    import win32api
    long_file_name='C:\Program Files\I am a file'
    short_file_name=win32api.GetShortPathName(long_file_name)
    

    【讨论】:

      【解决方案2】:

      【讨论】:

      猜你喜欢
      • 2017-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多