如果我以这种方式打印 xml 文档:
print(doc.toprettyxml(indent=' '*spaces, encoding='utf-8'))
我懂了:
b'<?xml version="1.0" encoding="utf-8"?>\n<element att=""/>\n'
我怎样才能摆脱b'前缀和'后缀?
尝试使用decode
:
print(doc.toprettyxml(indent=' '*spaces, encoding='utf-8').decode('utf-8'))