2012-04-27 58 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'))