ValueError:无法将字符串转换为浮点:“42999”(Python)

2024-03-29 11:51:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我不知道我的代码有什么问题:

def check_Price():
   title = soup.find(id="productTitle").get_text()
   price = soup.find(id="priceblock_ourprice").get_text()
   converted_price=float(price[2:8])

  if(converted_price>42,999):
     send_mail()
  )

运行此代码后,会出现以下错误:

converted_price=float(price[2:8])
ValueError: could not convert string to float: '42,999'

Tags: 代码textidgettitledefcheckfind