Discuss / Python / 交作业

交作业

Topic source

小小肥民

#1 Created at ... [Delete] [Delete and Lock User]

做得比较简单吧,也不知道有没什么bug

import os import os.path

def search_os(text,path): for a_dir in os.listdir(path): #从头开始检录 a_path = os.path.normpath('%s\%s' % (os.path.abspath('.'),a_dir)) if os.path.isdir(a_dir): #判断是否为目录 search_os(a_path,text) #递归 else: if text in a_dir: print(a_path)


  • 1

Reply