【发布时间】:2014-10-29 09:38:37
【问题描述】:
我正在使用 Python BeautifulSoup 版本 3。 我的 xml 看起来像这样(它来自 docx 格式):-
<w:r w:rsidRPr="00541D75">
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:cs="Times New Roman"/>
<w:b/>
<w:color w:val="1F497D" w:themeColor="text2"/>
<w:sz w:val="24"/>
<w:szCs w:val="24"/>
</w:rPr>
<w:t>Mandatory / Optional</w:t>
</w:r>
</w:p>
</w:tc>
</w:tr>
我想从标签'w:t'中提取内容,所以我就是这样做的:-
print soup.findAll('w:t')
这是我收到的错误消息:-
print soup.findAll('w:t')
UnicodeEncodeError: 'ascii' codec can't encode character u'\u201c' in position 43: ordinal not in range(128)
【问题讨论】:
标签: python xml beautifulsoup