AttributeError:“目录”对象没有属性“组件”

2024-09-28 22:22:27 发布

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

我写了这个代码

但我总是得到这样一个错误:AttributeError:“Catalog”对象没有属性“component”。问题是我看不出问题出在哪里。有什么问题吗(可能是压痕?)。谢谢

下面是它发现错误的代码段

完整错误代码

 Traceback (most recent call last)
  File "C:/Users/lukasz.karasinski/Adobe CC 2020/Adobe CC 2020/Photoshop/main.py", line 186, in <module>
    catalog.export_to_sql()
  File "C:/Users/lukasz.karasinski/Adobe CC 2020/Adobe CC 2020/Photoshop/main.py", line 90, in export_to_sql
    self.export_suites_to_sql(sql_file)
  File "C:/Users/lukasz.karasinski/Adobe CC 2020/Adobe CC 2020/Photoshop/main.py", line 107, in export_suites_to_sql
    suite_guid, suite.catalog_manufacturer_guid)
  File "C:/Users/lukasz.karasinski/Adobe CC 2020/Adobe CC 2020/Photoshop/main.py", line 110, in export_components_to_sql
    for key, component in self.component.items():
AttributeError: 'Catalog' object has no attribute 'component'

Tags: toinpysqlmainlineexportusers
1条回答
网友
1楼 · 发布于 2024-09-28 22:22:27

追溯显示了问题所在

for key, component in self.component.items():

在这一行中,self引用了Catalog类,正如错误告诉您的那样,它没有任何名为component的属性。在init方法中定义一个名为components的属性

class Catalog:
    def __init__(self):
        self.file_signatures = {}
        self.components = {}

利克利,你打错了,应该改一下

for key, component in self.component.items():

for key, component in self.components.items():

相关问题 更多 >