我需要在字典中創建集合。在字典中創建集合
dicInvertedIndex = {}
docID = 1
for i in string:
if condition:
docID += 1
dicInvertedIndex[i] = [1, set(docID)]
,我有一個錯誤:
dicInvertedIndex[i] = [1, set(docID)]
TypeError: 'int' object is not iterable
我想在這之前,我在字典中創建的列表和它的作品。
dicInvertedIndex[i] = [ 1 , [ docID ] ]
它工作。我需要創建我的文檔的鑰匙和(int
,set()
)
值的字典一樣dic["awake"] = [5, {2, 30, 99, 234}]
原來我用了一個列表,但它的速度慢了,我想用一組。
'不可迭代'聽起來像是'for'循環。仔細檢查'string'中的內容。 – Kevin
您應該詢問如何解決您的基本問題,而不是爲什麼您的嘗試解決方案無法正常工作。 – roippi
好的,謝謝。我問另一個問題 – Denis