def append_qs(url, query_string):
parsed_url = urlsplit(url)<EOL>parsed_qs = parse_qsl(parsed_url.query, True)<EOL>if isstr(query_string):<EOL><INDENT>parsed_qs += parse_qsl(query_string)<EOL><DEDENT>elif isdict(query_string):<EOL><INDENT>for item in list(query_string.items()):<EOL><INDENT>if islist(item[<NUM_LIT:1>]):<EOL><INDENT>for val in item[<NUM_LIT:1>]:<EOL><INDENT>parsed_qs.append((item[<NUM_LIT:0>], val))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>parsed_qs.append(item)<EOL><DEDENT><DEDENT><DEDENT>elif islist(query_string):<EOL><INDENT>parsed_qs += query_string<EOL><DEDENT>else:<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>return urlunsplit((<EOL>parsed_url.scheme,<EOL>parsed_url.netloc,<EOL>parsed_url.path,<EOL>urlencode_unicode(parsed_qs),<EOL>parsed_url.fragment,<EOL>))<EOL>
Append query_string values to an existing URL and return it as a string.

    query_string can be:
        * an encoded string: 'test3=val1&test3=val2'
        * a dict of strings: {'test3': 'val'}
        * a dict of lists of strings: {'test3': ['val1', 'val2']}
        * a list of tuples: [('test3', 'val1'), ('test3', 'val2')]