【发布时间】:2021-05-13 09:31:47
【问题描述】:
嗨,我想给 int,我编码了这个
async def limit(ctx, amount : int):
await ctx.send("Limit is : "+amount)
但我得到了这个错误: TypeError:只能将str(不是“int”)连接到str
我该怎么办?
【问题讨论】:
标签: python-3.x discord discord.py
嗨,我想给 int,我编码了这个
async def limit(ctx, amount : int):
await ctx.send("Limit is : "+amount)
但我得到了这个错误: TypeError:只能将str(不是“int”)连接到str
我该怎么办?
【问题讨论】:
标签: python-3.x discord discord.py
将整数改为字符串。
async def limit(ctx, amount : int):
await ctx.send("Limit is : "+str(amount))
【讨论】:
将整数转换为字符串、格式化字符串或使用 f-strings
await ctx.send("Limit is : " + str(amount)) # casting
await ctx.send("Limit is : {}".format(amount)) # formatting
await ctx.send(f"Limit is : {amount}") # f-string
【讨论】: