cgi escape(" hello" ' &lt; &lt; &gt;hello&lt;/ &gt;python' cgi module automatically converts characters that are special in html syntax according to the html convention it translates and with an extra true argument"into escape sequences of the form & ;where the is mnemonic that denotes the original character for instance&ltstands for the "less thanoperator (<and &ampdenotes literal ampersand (&there is no unescaping tool in the cgi modulebecause html escape code sequences are recognized within the context of an html parserlike the one used by your web browser when page is downloaded python comes with full html parsertooin the form of the standard module html parser we won' go into details on the html parsing tools here (they're covered in in conjunction with text processing)but to illustrate how escape codes are eventually undonehere is the html parser module at work reading back the preceding outputimport cgihtml parser cgi escape(" hello" ' &lt; &lt; &gt;hello&lt;/ &gt;html parser htmlparser(unescape( ' hellothis uses utility method on the html parser class to unquote in we'll see that using this class for more substantial work involves subclassing to override methods run as callbacks during the parse upon detection of tagsdataentitiesand more for more on full-blown html parsingwatch for the rest of this story in escaping urls by contrasturls reserve other characters as special and must adhere to different escape conventions as resultwe use different python library tools to escape urls for transmission python' urllib parse module provides two tools that do the translation work for usquotewhich implements the standard %xx hexadecimal url escape code sequences for most nonalphanumeric charactersand quote_pluswhich additionally translates spaces to signs the urllib parse module also provides functions for unescaping quoted characters in url stringunquote undoes %xx escapesand unquote_plus also changes plus signs back to spaces here is the module at workat the interactive promptimport urllib parse urllib parse quote(" # "' % % % % % % % server-side scripting