Python: getting filename case as stored in Windows?

前端 未结 6 1683
终归单人心
终归单人心 2020-12-17 15:01

Though Windows is case insensitive, it does preserve case in filenames. In Python, is there any way to get a filename with case as it is stored on the file system?

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-17 15:10

    I had problems with special characters with the win32api solution above. For unicode filenames you need to use:

    win32api.GetLongPathNameW(win32api.GetShortPathName(path))
    

提交回复
热议问题