我试图创建一个事件,如果有人离开服务器,那么他将从阵列中删除
代码:
@client.event
async def on_member_remove(member):
with open('users.json', 'r') as f:
users = json.load(f)
users.remove(member.id)
with open('users.json', 'w') as f:
json.dump(users, f)
错误:
AttributeError: 'dict' object has no attribute 'remove'
字典没有
remove()
.使用运算符从字典中删除元素
del
: