0
I want to extract the name of an image with its given extension uses full URL, for example:
image_url = 'http://dominio.com.br/caminho/da/imagem/imagem.png'
I want to have only:
image = 'imagem.png'
There is a ready-made Python function to simplify this?
In that case because I would need to import the module
urlsplit
? The functionsplit
alone is not a conventional method for doing this?– WhoisMatt
@Whoismatt are not euivalentes. There are other parts that could exist in the URL that function
split
does not consider. For example, in the URLhttp://localhost/imagem.png?cache=false#foo
by just doing thesplit
you would haveimagem.png?cache=false#foo
. With theurlsplit
we were able to separate each part of the URL and analyze only the path of the same, ignoring the query strings and Fragment.– Woss
Got it, thanks for the tip. I will now use this module then :)
– WhoisMatt