html escape python code example Example: escape string for html python import html s = '<p>&<\p>' e = html.escape(s) # = '<p>&<\p>'