【发布时间】:2016-06-23 09:49:13
【问题描述】:
我在从字符串中提取浮点数时遇到问题。该字符串是网页抓取的输出:
input = u'<strong class="ad-price txt-xlarge txt-emphasis " itemprop="price">\r\n\xa3450.00pw</strong>'
我想得到:
output: 3450.00
但我没有找到办法。我尝试使用拆分/替换功能将其提取出来:
word.split("\xa")
word.replace('<strong class="ad-price txt-xlarge txt-emphasis " itemprop="price">\r\n\xa','')
我尝试使用re 库。它也不好用,它只提取450.00
import re
num = re.compile(r'\d+.\d+')
num.findall(word)
[u'450.00']
因此,\ 最后我仍然有同样的问题
你有想法吗 ?
【问题讨论】:
-
你尝试了什么?
-
什么意思?我尝试使用的功能?
-
是的.. 我们希望查看您的代码,以便我们可以帮助您找出哪里出错
标签: python unicode split web-scraping