&#xxxx 是什么编码格式? py2 怎么将汉字转换为这种形式? XML 里用的
&#xxxx 是什么编码格式? py2 怎么将汉字转换为这种形式? XML 里用的
|
ClericPyJan 24, 2021
1
# -*- coding: utf-8 -*-
from html import escape print(escape(u'中文').encode('ascii', 'xmlcharrefreplace').decode('u8')) python - Convert HTML entities to Unicode and vice versa - Stack Overflow - https://stackoverflow.com/questions/701704/convert-html-entities-to-unicode-and-vice-versa |
|
mxT52CRuqR6o5Jan 24, 2021
2
HTML 转义字符?
|
|
3
xxxx 是十进制的 unicode,所以你只需要把每个字符转成 code 就行。
或者 &#xyyyy; 类似 yyyy 是十六进制格式。 |
|
ClericPyJan 24, 2021
5
|