How to get the filename without the extension from a path in Python?

前端 未结 23 1476
逝去的感伤
逝去的感伤 2020-11-22 05:43

How to get the filename without the extension from a path in Python?

For instance, if I had "/path/to/some/file.txt", I would want "

23条回答
  •  礼貌的吻别
    2020-11-22 06:34

    But even when I import os, I am not able to call it path.basename. Is it possible to call it as directly as basename?

    import os, and then use os.path.basename

    importing os doesn't mean you can use os.foo without referring to os.

提交回复
热议问题