怪事了怪事了!!
import osa = ''
i = 0
import sys
sys.setrecursionlimit(1000)
def find (want_file,want_path):
os.chdir(want_path)
allfile = os.listdir()
global a,i
print(allfile)
for each in allfile:
if os.path.isdir(each)==1:
want_path = os.path.join(os.getcwd(),each)
a = os.getcwd()
find(want_file,want_path)
elifwant_file == os.path.basename(each):
print(os.path.join(os.getcwd(),each))
os.chdir(a)
i += 1
return 0
while 1:
want_file = input('请输入待查找的目标文件:')
want_path = input('请输入需要查找的初始目录:')
find(want_file,want_path)
print(i)
这段代码的递归只能走十下!为神马呢?
页:
[1]