Python: getting filename case as stored in Windows?

前端 未结 6 1690
终归单人心
终归单人心 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:19

    Here's the simplest way to do it:

    >>> import win32api
    >>> win32api.GetLongPathName(win32api.GetShortPathName('texas.txt')))
    'TEXAS.txt'
    

提交回复
热议问题