这是因为在python3中keys不允许切片,先转List再切片就好了 示例: 将下行的代码:firstStr = inputTree.keys()[0] 转为:firstStr = list(inputTree.keys())[0] 即可