修改方法为:将firstStr= myTree.keys()[0]修改为firstStr=list(myTree.keys())[0]即可,原因是keys不允许切片,必须转为转为list再切片。
机器学习实战——TypeError:dict_keys' object is not subscriptable
最新推荐文章于 2023-11-09 10:24:15 发布
修改方法为:将firstStr= myTree.keys()[0]修改为firstStr=list(myTree.keys())[0]即可,原因是keys不允许切片,必须转为转为list再切片。