def urlencode(query):
if hasattr(urllib, '<STR_LIT>'):<EOL><INDENT>return urllib.parse.urlencode(query)<EOL><DEDENT>else:<EOL><INDENT>return urllib.urlencode(query)<EOL><DEDENT>
Encode string to be used in urls (percent encoding).

    :param query: string to be encoded
    :type query: str
    :return: urlencoded string
    :rtype: str

    :Example:
        >>> urlencode('pekná líščička')
        'pekn%C3%A1%20l%C3%AD%C5%A1%C4%8Di%C4%8Dka'