Discuss / Python / 第二题

第二题

Topic source
import os

name = input('input name of finding file: ')


def findfile(name,path='.'):
    print('path : %s'%path)
    pwd = os.path.abspath(path)
    print(os.listdir(pwd))
    for f in os.listdir(pwd):
        if os.path.isdir(f):
            findfile(name,f)
        if os.path.isfile(f) and (name in os.path.split(f)[1]):
            print('The file in:')
            print(os.path.join(pwd,f))

findfile(name)

参考的 @青春的青春C


  • 1

Reply