jeff2 urlencode with multiple values
public python v1 · immutableimport typesimport urllibdef urlencode2(d): a = [] for k in d: v = d[k] if type(v) == types.ListType: for x in v: a.append(urllib.urlencode({k: x})) else: a.append(urllib.urlencode({k: v})) return "&".join(a)print urlencode2({"a": ["b", "c"]})# Output: a=b&a=cprint urllib.urlencode({"a": ["b", "c"]})# Output: wrong