import html
s="<div>jsdlfjsl/>>>"
b=html.escape(s)
print(b)
c=html.unescape(b)
print(c)
<div>jsdlfjsl/>>>
<div>jsdlfjsl/>>>
url编码解码
from urllib import parse
str1 = 'haha哈哈'
str2 = parse.quote(str1) #quote()将字符串进行编码
print(str2) #str2=haha%E5%93%88%E5%93%88
str3 = parse.unquote(str2) #解码字符串
print(str3) #str3=haha哈哈
haha%E5%93%88%E5%93%88
haha哈哈