使用 python 和 BeautifulSoup 抓取数据时 Float 的横向无效

Invalid Lateral for Float while scraping data with python and BeautifulSoup

我正在尝试从网站导入股票价格。它将价格作为字符串导入,但当我尝试将其更改为浮点数时出现以下错误:

ValueError: invalid literal for float()

这是我的代码。

import requests
from bs4 import BeautifulSoup

#<span class="current-price" style="color:#D22B00">1,780</span>

request = requests.get("http://www.sharesansar.com/company/EBL")

content = request.content

soup = BeautifulSoup(content, "html.parser")

span_line = soup.find("span", {"class":"current-price", "style":"color:#D22B00"})

price = span_line.text.strip()

stock_price = float(price)
price = span_line.text.strip().replace(',', '')

1,780在python中无效,去掉,

class float([x])

If the argument is a string, it should contain a decimal number, optionally preceded by a sign, and optionally embedded in whitespace. The optional sign may be '+' or '-'; a '+' sign has no effect on the value produced.