How can I find path to given file?

后端 未结 6 1345
伪装坚强ぢ
伪装坚强ぢ 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

    Uh... This question is a bit unclear.

    What do you mean "have"? Do you have the name of the file? Have you opened it? Is it a file object? Is it a file descriptor? What???

    If it's a name, what do you mean with "find"? Do you want to search for the file in a bunch of directories? Or do you know which directory it's in?

    If it is a file object, then you must have opened it, reasonably, and then you know the path already, although you can get the filename from fileob.name too.

提交回复
热议问题