[英]Python html2text text issue
i am using html2text
for converting Html into text, but its also changing my text strings as well eg A&P
to A&P;
我正在使用
html2text
将HTML转换为文本,但是它也更改了我的文本字符串,例如A&P
到A&P;
html2text
how i can avoid this change 我如何避免这种变化
In [1]: import html2text
In [2]: conv = html2text.HTML2Text()
In [3]: conv.handle("string A&P string")
P
&P;
Out[3]: u'string A&P; string\n\n'
output should be 输出应该是
Out[3]: u'string A&P string\n\n'
It's because the string you convert has syntax error. 这是因为您转换的字符串存在语法错误。 & should be escaped in html language.
&应该以html语言转义。
Try 尝试
out = conv.handle("string A&P string")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.