【问题标题】:Float number cannot read context from discord?浮点数无法从不和谐中读取上下文?
【发布时间】:2020-01-24 10:09:10
【问题描述】:

试图为我的网站制作网站货币计算器,问题是它有浮动值,它说 TypeError: float() argument must be a string or a number, not '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 上尝试过它并且它工作,但它不适用于不和谐。

【问题讨论】:

    标签: python-3.x beautifulsoup floating-point calculator discord.py-rewrite


    【解决方案1】:
    @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))
    

    好像我已经成功了

    【讨论】:

      猜你喜欢
      • 2023-03-13
      • 1970-01-01
      • 2012-01-15
      • 1970-01-01
      • 2014-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多