[尝试为我的网站制作一个用于网站货币的计算器,问题是它具有浮动值,它说TypeError:float()参数必须是字符串或数字,而不是'Context'
将上下文设为浮动
@x.command()
async def cal(ctx):
veela = requests.get('https://veela.csne.host')
soup = BeautifulSoup(veela.content, 'html.parser')
ar = ""
for text in soup.findAll("h2",attrs={'class':'display-3 font-weight-bold text-uppercase mb-0 animated fadeIn delay-1s'}):
ar += f'{text.text}'
xe = float(ar)+float((ctx))
print(xe)
await ctx.send(float(xe))
我希望此输出能够正常工作,因为我在CMD上对其进行了尝试,并且可以正常工作,但对于不一致的情况不起作用。
@x.command()
async def cal(ctx, arg: float):
veela = requests.get('https://veela.csne.host')
soup = BeautifulSoup(veela.content, 'html.parser')
ar = ""
for text in soup.findAll("h2",attrs={'class':'display-3 font-weight-bold text-uppercase mb-0 animated fadeIn delay-1s'}):
ar += f'{text.text}'
xe = float(ar)+float((arg))
print(xe)
await ctx.send(float(xe))