20.1. html
— Suporte HTML(HyperText Markup Language)¶
Código fonte :fonte:`Lib/html/__init__.py`
Este módulo define utilitários para manipular HTML.
-
html.
escape
(s, quote=True)¶ Converte os caracteres
&
,<
e>
na string s para sequências seguras em HTML. Use se necessitar mostrar texto que possa conter estes caracteres no HTML. Se o flag opcional quote é true, os caracteres ("
) e ('
) também são convertidos; isso auxilia na inclusão de valores delimitados por aspas num atributo HTML, como em<a href="...">
.Novo na versão 3.2.
-
html.
unescape
(s)¶ Convert all named and numeric character references (e.g.
>
,>
,&x3e;
) in the string s to the corresponding unicode characters. This function uses the rules defined by the HTML 5 standard for both valid and invalid character references, and thelist of HTML 5 named character references
.Novo na versão 3.4.
Sub módulos no pacote html
são:
html.parser
– analisador HTML/XHTML com modo de análise brandahtml.entities
– definições das entidade HTML