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']