def getNumleafs(myTree):
numLeafs =0#初始化节点数
firstSides = list(myTree.keys())#先把最广的key遍历
firstStr = firstSides[0]#取第一个key
secondDict = myTree[firstStr]#取第一个key的子字典
#=>Traceback (most recent call last):
File "/Users/admin/PycharmProjects/untitled20/机器学习/决策树的实现.py", line 317, in <module>
createPlot(myDat)
File "/Users/admin/PycharmProjects/untitled20/机器学习/决策树的实现.py", line 98, in createPlot
plotTree.totalW = float(getNumleafs(inTree))
File "/Users/admin/PycharmProjects/untitled20/机器学习/决策树的实现.py", line 18, in getNumleafs
firstSides = dict(myTree.keys())#先把最广的key遍历
AttributeError: 'list' object has no attribute 'keys'
The problem was that the PY3.5 to PY3.6 had changed the rules within the dict uses