【发布时间】:2020-10-08 00:35:07
【问题描述】:
我制作了一个正在工作的“禁用模块”,但是当它加载到 json 文件中时,我收到一条错误消息。
@client.command(aliases=["disable economy"])
async def disable_economy(message):
with open('disable economy.json', 'r+') as f:
channel = json.load(f)
if not f'{message.channel.id}' in channel:
channel[f'{message.channel.id}'] = "Channel ID"
json.dump(channel, f)
await message.channel.send(f"Economy has been disabled in <#{message.channel.id}>. ")
return
if f'{message.channel.id}' in channel:
await message.channel.send("Economy is already disabled in this channel.")
return
执行命令后,它会加载到一个 json 文件中,如下所示:
{}{"750485129436201023": "Channel ID"},我得到的错误信息是:End of file expected。错误在第二个 {.有人可以帮忙吗?
【问题讨论】:
标签: python python-3.x discord.py discord.py-rewrite