我创建了下面的类。包、网站和评论都是字符串,District是(字符串,列表)字典。在class TableEntry(object):
def __init__(self, package, website, distroDict, comments):
self.package = package
self.website = website
self.distroDict = distroDict
self.comments = comments
我想使用defaultdict(TableEntry)来创建一个(string,TableEntry)自定义字典。在
^{pr2}$
我希望包是键,entry对象是值。我可以在entry对象中使用值,但是如果我试图将其附加到tableDict,则会收到以下错误。在Traceback (most recent call last):
File "wiki.py", line 151, in
printMetaData(lines, f)
File "wiki.py", line 73, in printMetaData
tableDict[package].append(entry)
TypeError: __init__() takes exactly 5 arguments (1 given)
我也尝试了以下方法:tableDict[package].append(TableEntry(package, website, distroDict, comments))
基本上收到相同的错误:Traceback (most recent call last):
File "wiki.py", line 150, in
printMetaData(lines, f)
File "wiki.py", line 73, in printMetaData
tableDict[package].append(TableEntry(package, website, distroDict, comments))
TypeError: __init__() takes exactly 5 arguments (1 given)