我想用 beautifulsoup 来提取数字。我的代码如下:
future=data3.find_all('span',class_='instrument-price_last__KQzyA')
print(future)
它将返回:
span class="instrument-price_last__KQzyA" data-test="instrument-price-last">23,989.5</span
如何从这些信息中提取 23989.5?谢谢你。
使用text
属性:
future = float(data3.find_all('span',class_='instrument-price_last__KQzyA').text.replace(',', ''))
和:
print(future)
会给:
23989.5
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句