this convention is known as the application/ -www-form-urlencoded query string formatand it' part of the magic behind those bizarre urls you often see at the top of your browser as you surf the web python html and url escape tools if you're like meyou probably don' have the hexadecimal value of the ascii code for committed to memory (though python' hex(ord( )can helpluckilypython provides tools that automatically implement url escapesjust as cgi escape does for html escapes the main thing to keep in mind is that html code and url strings are written with entirely different syntaxand so employ distinct escaping conventions web users don' generally careunless they need to type complex urls explicitly-browsers handle most escape code details internally but if you write scripts that must generate html or urlsyou need to be careful to escape characters that are reserved in either syntax because html and urls have different syntaxespython provides two distinct sets of tools for escaping their text in the standard python librarycgi escape escapes text to be embedded in html urllib parse quote and quote_plus escape text to be embedded in urls the urllib parse module also has tools for undoing url escapes (unquoteunquote_plus)but html escapes are undone during html parsing at large ( by python' html parser moduleto illustrate the two escape conventions and toolslet' apply each tool set to few simple examples somewhat inexplicablypython developers have opted to move and rename the cgi escape function used throughout this book to html escapeto make use of its longstanding original name deprecatedand to alter its quoting behavior slightly this is despite the fact that this function has been around for ages and is used in almost every python cgi-based web scripta glaring case of small group' notion of aesthetics trouncing widespread practice in and breaking working code in the process you may need to use the new html escape name in future python versionthat isunless python users complain loudly enough (yeshint!escaping html code as we saw earliercgi escape translates code for inclusion within html we normally call this utility from cgi scriptbut it' just as easy to explore its behavior interactivelyimport cgi cgi escape(' "spam"' more on html and url escapes