*)可以这样,不用保存递归中的变量

import os

def findFile (str,dir = os.path.abspath('.')):
    for x in os.listdir(dir):
        if os.path.isdir(os.path.join(dir,x)):
            findFile(str,os.path.join(dir,x))
        elif str in x:
            print(os.path.join(dir,x))#我一直都是想办法保存在递归的程序中

  

*)谁说while最少会执行一次的,并不是这样

>>> while a>2:
...     print(a)
...     a-=1
...
>>>
>>> a=3
>>> while a>2:
...     print(a)
...     a-=1
...
3
View Code

相关文章:

  • 2022-12-23
  • 2022-02-14
  • 2022-12-23
  • 2022-01-06
  • 2022-12-23
  • 2021-05-04
  • 2021-11-14
  • 2021-07-07
猜你喜欢
  • 2022-02-28
  • 2021-05-25
  • 2022-01-15
  • 2021-10-07
  • 2022-12-23
  • 2022-12-23
  • 2021-06-30
相关资源
相似解决方案