Last active
August 29, 2015 14:04
-
-
Save TheWaWaR/76ce7cfca7379cdabf68 to your computer and use it in GitHub Desktop.
Build url with params
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
def build_url(url, params): | |
query_string = '&'.join(['='.join([k, urllib.quote(v)]) for k, v in params.iteritems()]) | |
return '{}?{}'.format(url, query_string) | |
params = { | |
'abc':'some#def', | |
'integer': '234123' | |
} | |
url = 'http://www.example.com/query' | |
print build_url(url, params) | |
## http://www.example.com/query?integer=234123&abc=some%23def |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment