Get pathlib file name only

Asked

Viewed 61 times

-2

I currently have the following code:

from pathlib import Path

for file in Path("resources/maps").glob("*.json"):
    print(file)

Which returns:

resources\maps\map1.json
resources\maps\map2.json
resources\maps\map3.json

But I only need the file name, not the whole way to it...

Is there any method of pathlib itself for this?

Thanks in advance.

1 answer

-3


  • 1

    https://pt.meta.stackoverflow.com/q/7172/112052

  • 1

    I just tried to explain how the site works and how to improve your responses (at the time I was with little time to explain better, so I just left a link). It’s too bad you don’t want to understand. But I will try again and suggest another link: https://answall.com/conduct - I suggest you read and review your stance, and see my comments as constructive criticism. See you around

Browser other questions tagged

You are not signed in. Login or sign up in order to post.