Recursion While循环在True或False时输入

Recursion While循环在True或False时输入,recursion,while-loop,python-3.8,Recursion,While Loop,Python 3.8,当我运行这个函数时,它的输出是连续的 def func(l): 打印(f'开头不为空{不为空(l)}') 虽然不为空(l): 打印(f'in while循环isnull返回值为{isnull(l)}') islat(l[1:]) 返回“在返回时” 仅在I ctl-c之前运行的输出 >>func([“this”]) 在函数开始处:Not isnull(l)返回True 在while循环中:notisnull(l)返回True 在函数开始处:Not isnull(l)返回False 在while循

当我运行这个函数时,它的输出是连续的

def func(l):
打印(f'开头不为空{不为空(l)}')
虽然不为空(l):
打印(f'in while循环isnull返回值为{isnull(l)}')
islat(l[1:])
返回“在返回时”
仅在I ctl-c之前运行的输出

>>func([“this”])
在函数开始处:Not isnull(l)返回True
在while循环中:notisnull(l)返回True
在函数开始处:Not isnull(l)返回False
在while循环中:notisnull(l)返回True
在函数开始处:Not isnull(l)返回False
在while循环中:notisnull(l)返回True
在函数开始处:Not isnull(l)返回False
在while循环中:notisnull(l)返回True
在函数开始处:Not isnull(l)返回False

我不明白为什么在not isnull为True或False时输入while循环?

当给定表达式为True时,while循环将执行。在您的例子中,给定的表达式是
而不是isnull
。由于
isnull
False,
not isnull
为True,因此循环一直执行,直到
isnull
变为True

什么是isnull函数isnull测试isinstance列表是否为空。islat函数是什么我认为错误在于定义的方法,如islat和isnull。显示这些方法以了解您在做什么我被它弄糊涂了,首先进入while循环,值为True,然后在值为False时进入while循环,用于以下时间?