Open wheniseeyou opened 7 years ago
@wheniseeyou thank you, in python3.6 it may works by changing like this:
def getNumleafs(myTree):
numLeafs =0#初始化节点数
#firstSides = list(myTree.keys())
#firstStr = firstSides[0]
#secondDict = myTree[firstStr]
#for key in secondDict.keys():
for key in myTree.values():
if type(value).__name__=='dict':
numLeafs+=getNumLeafs(value)
else: numLeafs+=1
return numLeafs
The problem was that the PY3.5 to PY3.6 had changed the rules within the dict uses