py 3.x 修改版本问题

This commit is contained in:
jiangzhonglian
2020-03-15 14:38:41 +08:00
parent 11f94b0ed3
commit 758be028ee

View File

@@ -318,7 +318,7 @@ def classify(inputTree, featLabels, testVec):
classLabel 分类的结果值需要映射label才能知道名称
"""
# 获取tree的根节点对于的key值
firstStr = inputTree.keys()[0]
firstStr = list(inputTree.keys())[0]
# 通过key得到根节点对应的value
secondDict = inputTree[firstStr]
# 判断根节点名称获取根节点在label中的先后顺序这样就知道输入的testVec怎么开始对照树来做分类