2

我在python中的正则表达式有点麻烦。html字符串是:

html = <td style="padding-right:5px;">
<span class="blackText">Above £ 7.00 = </span>
</td>
<td>
<span class="blackText">
<p>Free</p>
</span>
</td>

我想提取“7.00”和“免费”,但是以下不起作用:

金额 = re.findall(r'Above £ (.*?) =',html)

Python 会为 £ 符号抛出一个非 ASCII 错误。我将如何解决这个问题?谢谢。

4

1 回答 1

5
amount = re.findall(r'Above \xC2 (.*?) =', html)
于 2012-11-29T18:50:14.260 回答