参数“name”转换为“int”失败

qyuhtwio  于 2021-08-25  发布在  Java
关注(0)|答案(1)|浏览(569)

有什么解决办法吗?

async def cosmetic(ctx, name : int):
    response = requests.get("https://fortnite-api.com/v2/cosmetics/br")
    embed=discord.Embed(
    title=f"{name}", color=0x9c3030
)
    embed.add_field(f'Rarity: {BrCosmeticRarity}')
    await ctx.send(embed=embed)
yrdbyhpb

yrdbyhpb1#

你在显式转换 nameint 通过

async def cosmetic(ctx, name : int):
``` `name` 但是,不应该是int类型,因为它可能是字符串。要解决问题,请为设置正确的类型 `name` 在函数声明中

async def cosmetic(ctx, name : str):

async def cosmetic(ctx, name : str):
response = requests.get("https://fortnite-api.com/v2/cosmetics/br")
embed=discord.Embed(
title=f"{name}", color=0x9c3030
)
embed.add_field(f'Rarity: {BrCosmeticRarity}')
await ctx.send(embed=embed)

相关问题