使用Python从XML文件读取表情符号

使用Python从XML文件读取表情符号,python,xml,python-requests,Python,Xml,Python Requests,我正在尝试从XML文件中读取表情符号。手动复制它们可以正常工作,并且可以打印它们并在浏览器中正确显示 import requests import xml.etree.ElementTree as ET root = ET.fromstring(requests.get('http://www.unicode.org/repos/cldr/trunk/common/annotations/en.xml').text) print(root[1][21].attrib['cp']) 这应该是

我正在尝试从XML文件中读取表情符号。手动复制它们可以正常工作,并且可以打印它们并在浏览器中正确显示

import requests
import xml.etree.ElementTree as ET

root = ET.fromstring(requests.get('http://www.unicode.org/repos/cldr/trunk/common/annotations/en.xml').text)

print(root[1][21].attrib['cp'])

这应该是“笑眯眯的脸”的回应。文本将解码内容(请参阅)。
ElementTree
再次解码已解码的字节(基于

尝试
Response.content
将未触及的响应传递给
ElementTree

import requests
import xml.etree.ElementTree as ET

root = ET.fromstring(requests.get('http://www.unicode.org/repos/cldr/trunk/common/annotations/en.xml').content)

print(root[1][21].attrib['cp'])

响应。文本将对内容进行解码(请参阅)。
ElementTree
再次解码已解码的字节(基于

尝试
Response.content
将未触及的响应传递给
ElementTree

import requests
import xml.etree.ElementTree as ET

root = ET.fromstring(requests.get('http://www.unicode.org/repos/cldr/trunk/common/annotations/en.xml').content)

print(root[1][21].attrib['cp'])