a = {'a': 'b', 'c': {'d': 'e'}}
url = urllib.parse.urlencode([(('%s[%s]' % (k, list(v.keys())[0]), list(v.values())[0]) if 
    type(v) == dict else (k, v)) for k, v in a.items()])
url = 'a=b&c%5Bd%5D=e'
urlencode a multidimensional dictionary in python