1 回答

TA貢獻(xiàn)1835條經(jīng)驗(yàn) 獲得超7個(gè)贊
您的open_account函數(shù)看起來(lái)不會(huì)執(zhí)行您需要執(zhí)行的操作。如果還沒(méi)有給定用戶的新帳戶,您需要它來(lái)創(chuàng)建一個(gè)新帳戶。但是您沒(méi)有任何代碼來(lái)檢查現(xiàn)有用戶(看起來(lái)您正在嘗試,但有一個(gè)拼寫錯(cuò)誤),并且您也沒(méi)有代碼來(lái)創(chuàng)建內(nèi)部字典。
這就是我認(rèn)為你想要的:
async def open_account(user):
users = await get_bank_data()
if str(user.id) in users: # note, use "in" here rather than "is"
return False
users[str(user.id)] = {"Simp Wallet": 0, "Simp Bank": 0} # create inner dictionary here
with open('mainbank.json',"w") as f:
json.dump(users,f)
return True
添加回答
舉報(bào)