Skip to content

Instantly share code, notes, and snippets.

View taojunxin's full-sized avatar

Coder Franklin taojunxin

View GitHub Profile
@taojunxin
taojunxin / snippet.py
Last active April 23, 2020 15:39
[获得URL里的文件名] #python #pathlib
from urllib.parse import urlparse
from pathlib import Path
url = "http://example.com/some/long/path/a_filename.jpg?some_query_params=true&some_more=true#and-an-anchor"
a = urlparse(url)
a.path # '/some/long/path/a_filename.jpg'
Path(a.path).name # 'a_filename.jpg'