我试图获得特定产品的评论次数
代码是:
total_reviews = soup.find("div", {"class": "feature"}).findNext(
"span", {"id": "acrCustomerReviewText"}).string
x = ''
for number in total_reviews:
if number == ' ':
break
else:
x = x + number
num_reviews =int(x)
答案 0 :(得分:0)
使用str.replace()
替换逗号为空字符串:
num_reviews = int(x.replace(",", ""))