我很难指出我在递归子例程中做错了什么。
惯例是:
def Validate(n):
err=''
for z in n:
if type(z)==list:
x=Validate(z)
if x!='':
err='%s%s, ' % (err,x)
else:
if 'err' in z:
print ('...found err:',z)
err='%s%s, ' % (err,z)
return err
testpar=['test','err1','err2', ['suberr1','subb'],'isok' ,'lasterr']
print ("Result:",Validate(testpar))
预期结果是:
err1, err2, suberr1, lasterr,
但我得到:
err1, err2, suberr1, , lasterr,
哆啦的时光机
相关分类