【发布时间】:2022-01-26 13:46:24
【问题描述】:
我的程序从kody.txt 文件中读取并在不和谐上打印它作为重播命令,我想从kody.txt 中删除打印的代码。这个怎么做?有任何想法吗?
atm 代码不起作用,因为 read_coupon() 返回空值(清除所有 txt 文件)
@client.command()
async def kody (ctx, amount):
await ctx.send(read_coupon(int(amount)))
def read_coupon(amount):
result = ''
with open("kody.txt","r") as f:
for line in f:
result += line
amount -= 1
if line == result:
line.replace(result," ")
if amount == 0: break
return result
kody.txt:
NLS8JS4L4J
NLZP8PPBQ2
NLXSTD7X6S
NLQ4PW7N4B
NLNR8EEAKA
NL3WXLQUS4
NLGCCHJ9Y9
NLW9ZT4UG7
NL26PKQYZH
NLNZBFK99S
【问题讨论】:
标签: python discord.py