human
Complete the below
def _encode_params(**kw):

    ''''Do url-encode parameters
    >>> _encode_params(a=1, b=\'R&D\')
    \'a=1&b=R%26D\'
    >>> _encode_params(a=u\'\u4e2d\u6587\', b=[\'A\', \'B\', 123])
    \'a=%E4%B8%AD%E6%96%87&b=A&b=B&b=123\''
    '''

Can you provide a the Python code you requested?
assistant
#Here is the Python code you requested.
    def _encode(L, k, v):
        if isinstance(v, unicode):
            L.append(('%s=%s' % (k, urllib.quote(v.encode('utf-8')))))
        elif isinstance(v, str):
            L.append(('%s=%s' % (k, urllib.quote(v))))
        elif isinstance(v, collections.Iterable):
            for x in v:
                _encode(L, k, x)
        else:
            L.append(('%s=%s' % (k, urllib.quote(str(v)))))
    args = []
    for (k, v) in kw.iteritems():
        _encode(args, k, v)
    return '&'.join(args)