1 回答

TA貢獻(xiàn)1810條經(jīng)驗(yàn) 獲得超5個(gè)贊
試試這個(gè)
TestDict = {0: {"ItemName" : "washing machine", "ItemStockLevel" : 15, "ItemCostPrice" : 129.21, "ItemSellingPrice" : 142.21},
1: {"ItemName": "french fries", "ItemStockLevel": 100, "ItemCostPrice": 21.51, "ItemSellingPrice": 41.77},
2: {"ItemName" : "magnum ice cream", "ItemStockLevel" : 30, "ItemCostPrice" : 57.32, "ItemSellingPrice" : 78.31}}
test = []
for key in TestDict:
test.append(TestDict[key]["ItemName"])
_end = '_end_'
def make_trie(list):
root = []
for word in list:
root.append(word)
return root
print(set(make_trie(test)))
輸出
{'magnum ice cream', 'french fries', 'washing machine'}
添加回答
舉報(bào)