【发布时间】:2022-01-26 00:16:36
【问题描述】:
您好,我有这个问题很长时间了,不知道如何处理它。我想像这样编程运行某事:
- 用户写入命令与参数(数量)不一致
- discord 函数将调用带有书面参数的 read_coupon 函数
- read_coupon 函数将打开并读取行(取决于数量)并从 txt 文件中返回
atm 我的代码忽略用户输入,只返回 kody.txt 中的第一行
@client.command()
async def kody (ctx, amount):
await ctx.send(read_coupon(int(amount)))
def read_coupon(amount):
x_range = range(0,amount,1)
kody_open = open("kody.txt","r")
for line_kod in kody_open:
kody_lista.append(line_kod)
for x in x_range:
for element in kody_lista:
return element
kody.txt
NLZGQEJ32W
NLBH9LBZVP
NLB6DRBZ4Q
NLJ8GWAC8M
NLBH9LBZVP
NLB6DRBZ4Q
NLJ8GWAC8M
【问题讨论】:
标签: python discord.py chatbot