2012-04-27 100 views
0

如果我打印的XML文档这种方式:蟒:打印XML文档

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

我得到这个:

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

我怎样才能脱身B '前缀和'后缀?

回答

4

尝试使用decode

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