def parse_qs(qs, keep_blank_values=0, strict_parsing=0, unquote=unquote):
 d = {}
 items = [s2 for s1 in qs.split('&') for s2 in s1.split(';')]
 for item in items:
  try:
   (k, v) = item.split('=', 1)
  except ValueError:
   if strict_parsing:
    raise
   continue
  if (v or keep_blank_values):
   k = unquote(k.replace('+', ' '))
   v = unquote(v.replace('+', ' '))
   if (k in d):
    d[k].append(v)
   else:
    d[k] = [v]
 return d

def parse_qs ( qs , keep_blank_values = 0 , strict_parsing = 0 , unquote = unquote ) : d = { } items = [ s2 for s1 in qs . split ( '&' ) for s2 in s1 . split ( ';' ) ] for item in items : try : ( k , v ) = item . split ( '=' , 1 ) except ValueError : if strict_parsing : raise continue if ( v or keep_blank_values ) : k = unquote ( k . replace ( '+' , ' ' ) ) v = unquote ( v . replace ( '+' , ' ' ) ) if ( k in d ) : d [ k ] . append ( v ) else : d [ k ] = [ v ] return d
parse a query given as a string argument .