我正在学习Python,但在这一刻陷入了困境:
from tkinter import *
import requests
from bs4 import BeautifulSoup
r = requests.get('https://www.nbg.gov.ge/index.php?m=582')
c = r.content
soup = BeautifulSoup (c, 'html.parser')
headers = soup.find('div', {'id': 'currency_id'})
table = headers.find('table')
listCurrency = table.find_all("td")
usdCurrency = listCurrency[-13].text.strip()
usdCurrency.replace(',', '.')
usdCurrency = int(usdCurrency)
result = int(input("Input Number")
result = result/usdCurrency
我得到了这个错误:
invalid literal for int() with base 10: '3.2896'
usdCurrency = int(usdCurrency)
TypeError: unsupported operand type(s) for /: 'int' and 'str'
出现这些错误的原因是,usdCurrency的值是小数(例如3.2896),并且您无法使用
这些代码行导致了错误,您应该使用它们来避免错误
一切都完成了
谢谢
相关问题 更多 >
编程相关推荐