我很難弄清楚如何從 vscode 更新方法的選定參考。右鍵單擊方法名稱不會提供選擇和更新參考的選項。Python 和 vscode 的新手,并試圖找出它周圍的細微差別。請有人幫我解決這個問題!
這是課程 - 我有一個課程 Player_Account
class Player_Account:
def __init__(self,owner,balance):
self.owner = owner
self.balance = balance
def deposit(self,balance):
self.balance = balance
return "Amount added to players pot !"
def withdraw(self,amount): # I need to update this method name to withdraw_amount
if self.balance<amount:
return "Funds Unavailable"
else:
self.balance -= amount
return "Money added to hand !"
def __str__(self):
return f"Account owner : {self.owner} has outstanding balance of {self.balance}"
另一個班級 Player
class Player:
def __init__(self,name):
self.name=name
self.hand = []
self.player_account:Player_Account = Player_Account(name,0)
def initial_money(self,amount):
self.player_account.balance = amount
def player_won_the_hand(self,amount):
self.player_account.deposit(amount)
return True
def player_betting_amount_for_the_round(self,amount):
value = self.player_account.withdraw(amount) # I need this reference to be automatically updated as well
if value == 'Funds Unavailable':
return False
else:
return True
uj5u.com熱心網友回復:
我剛試過。
- 設定游標
def withdraw - 按
F2(重命名符號) - 將名稱更改為
withdraw_amount并按Enter - 這需要幾秒鐘,但兩者都改變??了
我使用 PyLance。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/408585.html
標籤:
