未解析的属性引用

2024-10-02 16:23:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用PyCharm的新版本来处理Python。我收到了

Unresolved attribute reference 'ItemLocation' for class 'Item'

但是应用程序启动得很好,没有错误或崩溃,有什么想法吗?在

class Item:
    def __init__(self, state = '', location = '', realm = 'All', index =- 1):
        self.__dict__ = {
            'ActiveState': state,
            'ItemEquipped': 0,
            'ItemLocation': location,  # <-- DEFINED HERE
            'ItemRealm': realm,
            'ItemLevel': '51',
            'ItemQuality': '100',
            'ItemType': '',
            'ItemName': '',
            'ItemAFDPS': '',
            'ItemSpeed': '',
            'ItemBonus': '',
            'ItemSource': '',
            'LeftHand': '',
            'ItemDamageType': '',
            'ItemRestrictions': list(),
            'ItemNotes': '',
            'ItemRequirement': '',
            'TemplateIndex': index,
        }

        self.ItemSlotList = list()

        if self.ItemLocation in SlotList['Jewelery']:  # <-- HERE
            self.ActiveState = 'drop'
            self.ItemEquipped = 2
        elif self.ItemLocation in SlotList['Armor']:  # <-- HERE
            self.ActiveState = 'crafted'
            self.ItemEquipped = 2
        elif self.ItemLocation in SlotList['Weapons']:  # <-- HERE
            self.ActiveState = 'drop'
            self.ItemEquipped = 0
        elif self.ItemLocation in SlotList['Mythical']:  # <-- HERE
            self.ActiveState = 'drop'
            self.ItemEquipped = 2

        # TODO: DETERMINE 'ItemEquipped' FOR WEAPONS BASED ON CLASS SELECTION

        self.ItemSlotList = self.makeItemSlots()

抱歉,如果事情看起来很糟糕,我还在学习。我在运行python3和PyQt5


Tags: inselfindexherelocationitemclassdrop