我開始學習Python和無法理解,這裏是錯誤UnboundLocalError在__init__
class Gun(object):
def __init__(self, magazine=6):
self.__dict__["magazine"] = magazine
self.__dict__["ammo"] = ammo
錯誤日誌
self.__dict__["ammo"] = ammo
UnboundLocalError: local variable 'ammo' referenced before assignment