def _encode_params(**kw):
 args = []
 for (k, v) in kw.iteritems():
  if isinstance(v, basestring):
   qv = (v.encode('utf-8') if isinstance(v, unicode) else v)
   args.append(('%s=%s' % (k, urllib.quote(qv))))
  elif isinstance(v, collections.Iterable):
   for i in v:
    qv = (i.encode('utf-8') if isinstance(i, unicode) else str(i))
    args.append(('%s=%s' % (k, urllib.quote(qv))))
  else:
   qv = str(v)
   args.append(('%s=%s' % (k, urllib.quote(qv))))
 return '&'.join(args)

def _encode_params ( ** kw ) : args = [ ] for ( k , v ) in kw . iteritems ( ) : if isinstance ( v , basestring ) : qv = ( v . encode ( 'utf-8' ) if isinstance ( v , unicode ) else v ) args . append ( ( '%s=%s' % ( k , urllib . quote ( qv ) ) ) ) elif isinstance ( v , collections . Iterable ) : for i in v : qv = ( i . encode ( 'utf-8' ) if isinstance ( i , unicode ) else str ( i ) ) args . append ( ( '%s=%s' % ( k , urllib . quote ( qv ) ) ) ) else : qv = str ( v ) args . append ( ( '%s=%s' % ( k , urllib . quote ( qv ) ) ) ) return '&' . join ( args )
do url-encode parameters .