我想在文件中附加一行,然后发送(使用discord.py)。我不希望原始文件与新行一起保存,所以我要么想要删除之后添加的行,要么根本不更改原始文件。
我似乎无法弄清楚如何删除它,这是代码(它不会删除最后一行)。
if command == "beta":
betawrite = open("otbeta.txt", "a")
betawrite.write(str(message.author.id))
betawrite.close()
with open("otbeta.txt", 'rb') as betaOT:
await message.author.send("File.")
await message.author.send(file=discord.File(betaOT, 'beta.cfg'))
await message.delete()```