Python split url to find image name and extension

后端 未结 7 1978
逝去的感伤
逝去的感伤 2021-02-04 13:43

I am looking for a way to extract a filename and extension from a particular url using Python

lets say a URL looks as follows

picture_page = \"http://dis         


        
7条回答
  •  被撕碎了的回忆
    2021-02-04 14:15

    os.path.splitext will help you extract the filename and extension once you have extracted the relevant string from the URL using urlparse:

       fName, ext = os.path.splitext('yourImage.jpg')
    

提交回复
热议问题