How can I find path to given file?

后端 未结 6 1343
伪装坚强ぢ
伪装坚强ぢ 2020-12-16 22:00

I have a file, for example \"something.exe\" and I want to find path to this file
How can I do this in python?

6条回答
  •  悲哀的现实
    2020-12-16 22:28

    Perhaps os.path.abspath() would do it:

    import os
    print os.path.abspath("something.exe")
    

    If your something.exe is not in the current directory, you can pass any relative path and abspath() will resolve it.

提交回复
热议问题