python - How can I extract City, Region, Country from URL? Django -


my search field returns this:

http://localhost:8000/search/?city=new+york%2c+ny%2c+united+states

how can extract city, region, country. i've been through document: https://docs.python.org/2/library/urlparse.html

and question:

how can extract city, region, country url? django

but not sure how seperate them.

python 2.7

>>> urlparse import urlparse, parse_qs >>> u = urlparse('http://localhost:8000/search/?city=new+york%2c+ny%2c+united+states') >>> q = parse_qs(u.query) >>> q['city'] ['new york, ny, united states'] >>> q['city'][0].split(', ') ['new york', 'ny', 'united states'] 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

python 3.x - PyQt5 - Signal : pyqtSignal no method connect -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)