def _encode_params(kw):
    '''
    Encode parameters.
    '''
    args = []
    for k, v in kw.items():
        try:
            # Python 2
            qv = v.encode('utf-8') if isinstance(v, unicode) else str(v)
        except:
            qv = v
        args.append((k, urlquote(qv)) % '%s=%s')
    return '&'.join(args)
dataset/ETHPy150Open michaelliao/githubpy/github.py/_encode_params/swapped operands of `%`