python - 如何使用python从JSON中删除特定成员
问题描述
我尝试了不同的方法,但没有任何效果。当他离开服务器时,我想从 JSON 中删除特定成员。意图开启,其余代码运行良好。有小费吗?
@client.event
async def on_member_remove(member):
with open("users.json", "r") as f:
users = json.load(f)
del users[member.id]
with open("users.json", "w") as f:
json.dump(users, f)
例如,我想从 JSON 中删除“801014207230640168”
{"801014207230640168": {"xp": 11, "level": 1, "last_message": 1614718416.40123, "name": "BlackF00xTest"}}
解决方案
推荐阅读
- facebook - facebook页面被标记的帖子
- excel - Excel Vlookup lookup_value 用法
- javascript - 从头开始创建 Jquery UI Slider
- mysql - 查询选择连接表中的选择和where if条件
- visual-studio - Visual Studio 更新 15.8.1+ 构建问题
- javascript - 如何在 Highcharts 中重置图例区域中的项目?
- node.js - MongoDB 多语言 - 切换案例
- angular - 为什么 Angular 4 FormGroup 自定义验证器不起作用?
- dart - 切换语言时的国际化问题
- c# - 将 Powershell Connect-PnPOnline 转换为 C#