python怎么强制结束递归函数
lewis
2019-04-04
27次阅读
在python中强制结束递归函数的方法以下两种
1.使用return语句结束
def count(dict, key, depth):
if key is not None:
if key == 42:
return depth
return count(map, map[key][0], depth+1)
return count(map, map[key][1], depth+1)
2.通过在递归函数外定义一个isGo全局变量结束
var isGo:Boolean=true
functionarr_all(pre:Array,nex:Array) {
if(isGo==false){return}
var j:uint=nex.length;
if (j==1) {
var t=[];
for (var i:uint=0;i

发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。