第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

當(dāng)我在 python 中使用 while 循環(huán)運(yùn)行命令時(shí),我遇到了數(shù)量問題

當(dāng)我在 python 中使用 while 循環(huán)運(yùn)行命令時(shí),我遇到了數(shù)量問題

慕村225694 2023-06-13 17:07:01
我導(dǎo)入了一個(gè) json 文件并為超級大米的大米銀行帳戶創(chuàng)建了一個(gè) while 循環(huán)。我在父代碼下創(chuàng)建 def 但遇到錯(cuò)誤:TypeError: withdraw_money() missing 1 required positional argument: 'amount'。我還嘗試為每個(gè)子類設(shè)置新的一周新值,這些子類將為超級大米帳戶和預(yù)付附加 500,為普通大米 A 附加 0。由于錯(cuò)誤,我被 SuperRiceAccount.withdraw_money(amount) 困住了,我仍然需要找出新一周的功能。誰能幫我?下面是我的代碼class BaseAccount:      def __init__(self, account_id, account_type, full_name, birthday, balance,amount=500):        self.account_id = account_id        self.account_type = account_type        self.full_name = full_name        self.birthday = birthday        self.balance = balance        self.amount = amount    def account_info(self):        for p in data ['accounts']:            print('You have successfully withdrawn 500 grams from the account.')            print('Account ID:' + p['account_id'])            print('Account Type:' + p['account_type'])            print('Full Name:' + p['full_name'])            print('Birthday:' + p['birthday'])        print('Balance: ' + self.balance + ' left')    def withdraw_money(self, amount):        self.balance = self.balance - amount(500)        for p in data['accounts']:            print('You have successfully withdrawn 500 grams from the account.')            print('Account ID:' + p['account_id'])            print('Account Type:' + p['account_type'])            print('Full Name:' + p['full_name'])            print('Birthday:' + p['birthday'])            print('Balance: ' + self.balance + ' left')    def new_week(self):        returnclass SuperRiceAccount(BaseAccount):    def __init__(self, account_id, account_type, full_name, birthday, balance):        super().__init__(account_id, account_type, full_name, birthday, balance)        if self.balance >= 2000:            print ('You still have ', self.balance, ' left.')        else:            print('You do not have enough balance.')    def new_week(self):        if initial_balance < 2000:            self.balance = self.balance + 500            print('Your new balance is ', self.balance, ' left')
查看完整描述

1 回答

?
富國滬深

TA貢獻(xiàn)1790條經(jīng)驗(yàn) 獲得超9個(gè)贊

SuperRiceAccount調(diào)用方法時(shí)應(yīng)使用對象withdraw_money。
發(fā)生的情況是,當(dāng)您調(diào)用該函數(shù)時(shí),金額作為第一個(gè)參數(shù)傳遞,因此缺少self第二個(gè)參數(shù)。 通過初始化修復(fù)它:amount


bank = SuperRiceAccount([PASS HERE INITIALIZATION PARAMETERS])

并致電:

bank.withdraw_money(amount)
bank.account_info(amount)


查看完整回答
反對 回復(fù) 2023-06-13
  • 1 回答
  • 0 關(guān)注
  • 133 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號