Skip to content

Instantly share code, notes, and snippets.

@ivermac
Last active August 14, 2018 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivermac/b0860d952ada4d960893eec10f9c77ca to your computer and use it in GitHub Desktop.
Save ivermac/b0860d952ada4d960893eec10f9c77ca to your computer and use it in GitHub Desktop.
Url encoding and decoding in python

python 2.7

Use urlencode from urllib for encoding and parse_qs from urlparse for decoding. urlencode takes a dict while parse_qs takes a string. I learned from this awesome link.

python 3.6

Use urlencode from urllib.parse for encoding and parse_qs from urllib.parse for decoding. urlencode takes a dict while parse_qs takes a string.

compatibility in both python 2.7 and 3.6 com

Install future package version 0.16.0. Import urlencode and parse_qs from future.moves.urllib.parse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment