简体   繁体   中英

Could not convert negative string to a float

def net_value(count, wait): wait.until(EC.visibility_of_element_located((By.XPATH, "//*[@class='additional_percent_value']"))) time.sleep(1) net_profit = driver.find_elements_by_class_name("additional_percent_value")[0].text.split(" %") net_profitfl = float(net_profit[0]) if net_profitfl > 0.0: net_value = float(net_profit[0]) profits.update({count: net_value}) positive_color = {count: net_value} print(colored(f'{positive_color}', 'green')) return net_value

It seems that the first character is not an ASCII minus sign but the Unicode version. Therefore change:

net_profitfl = float(net_profit[0])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM