繁体   English   中英

将html2text与html utf8一起使用

[英]Using html2text with html utf8

我对html2text有问题

input = "<h1 itemprop="name">B&#242; 33 M&#243;n</h1>"

我用

from stripogram import html2text
print html2text(input)
print html2text(input.decode('utf8'))

而我的结果

B 33 Mn

结果我需要

Bò 33 món

我该怎么做?

html2text(input)的结果是Unicode。 要使用print进行print ,您需要通过将其转换为UTF-8来将其降为每个字符8位:

from stripogram import html2text
print html2text(input).encode('utf-8')

将打印

# Bò 33 Món

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM