今天编程我的机器人我需要做的命令,将编辑json文件的公会设置
但出于某种原因,我犯了一个错误
Command raised an exception: TypeError: Object of type TextIOWrapper is not JSON serializable
我所做的就是这样
with open('database.json') as file:
loadedFile = json.load(file)
for checkingGuild in loadedFile["guilds"]:
if int(checkingGuild["guild-id"]) == ctx.guild.id:
guild = checkingGuild
break
guild["global-group-id"] = int(ID)
with open('database.json','w') as f:
json.dump(loadedFile,f, indent=4)
这个json.load(文件)正在解决这个问题,但我不知道为什么!当我加入公会的时候,这件事很好,但出于某种原因,这件事正在发生! 请回答,如果你知道如何修复它
目前没有回答
相关问题 更多 >
编程相关推荐