讓我解釋:
if config == "create":
if str(user.id) in submissions:
await ctx.send(embed=discord.Embed(title="ERROR", description='you already have a submission!', color=discord.Color.red()))
return
if len(submission_full) > 2 and len(submission_full) < 100:
submissions[str(user.id)] = {}
submissions[str(user.id)]["submission"] = submission_full
基本上我在這里是一個不和諧的提交命令,它創建一個提交并將其轉儲到一個 json 檔案中。我目前正在研究一個執行相同操作但相反的命令,因此如果您想撤消它會洗掉您的提交。
我的第一個想法是這樣做:
if config.lower() in ["delete","remove","undo","cancel"]:
await ctx.send(embed=discord.Embed(title="Removing Current Submission..", description="You will no longer have any submissions. You can create a new one at any time!", color=0xFFD700))
submissions[str(user.id)] = None
但它只是用“null”替換您的提交。
這是json檔案中的輸出:
{"710826704259645450": null}
幫助表示贊賞!
uj5u.com熱心網友回復:
你要:
del submissions[str(user.id)]
uj5u.com熱心網友回復:
您可以使用 :
submissions.pop(str(user.id))
然后傾倒它
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/361631.html
上一篇:將json讀取到Pandas資料框時出現“尾隨資料”錯誤
下一篇:jq:將陣列映射到csv欄位標題
