gpt4 book ai didi

python - 将 HTML 实体转换为 Unicode,反之亦然

转载 作者:IT老高 更新时间:2023-10-28 21:45:22 25 4
gpt4 key购买 nike

如何在 Python 中将 HTML 实体转换为 Unicode,反之亦然?

最佳答案

至于“反之亦然”(我需要自己,导致我找到这个没有帮助的问题,随后 another site which had the answer ):

u'some string'.encode('ascii', 'xmlcharrefreplace')

将返回一个纯字符串,其中任何非 ascii 字符都转换为 XML (HTML) 实体。

关于python - 将 HTML 实体转换为 Unicode,反之亦然,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/701704/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com