0

如果我以这种方式打印 xml 文档:

print(doc.toprettyxml(indent=' '*spaces, encoding='utf-8'))

我懂了:

b'<?xml version="1.0" encoding="utf-8"?>\n<element att=""/>\n'

我怎样才能摆脱b'前缀和'后缀?

4

1 回答 1

4

尝试使用decode

print(doc.toprettyxml(indent=' '*spaces, encoding='utf-8').decode('utf-8'))
于 2012-04-27T14:03:26.177 回答