Se você tem uma URL como
example.txt
https://logodix.com/logo/1667872.jpg?param=valuee você quer encontrar apenas a extensão do nome do arquivo (.jpg para este exemplo), use o seguinte código:
parse_extension.py
from urllib.parse import urlsplit
import os.path
url = "https://logodix.com/logo/1667872.jpg?param=value"
path = urlsplit(url).path
extension = os.path.splitext(path)[-1] # e.g. ".jpg"
Check out similar posts by category:
Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow