2016-03-12 168 views
-1

我想沒有得到評論的特定產品的計數ValueError異常:無效的字面INT()基數爲10:'12,652'

的代碼是:

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

的'int'在它逗號?真?來吧!還有祝你好運 ;-) – shellter

回答

0

替換逗號使用str.replace()一個空字符串:

num_reviews = int(x.replace(",", "")) 
相關問題