Discuss / Python / 第二题 。

第二题 。

Topic source
import ospath= input('输入查询路径:')xun=input('请输入要查询的文件包含的字符串:')def finpath(path):    for x in os.listdir(path):        mypath=os.path.abspath(os.path.join(path,x))        if os.path.isfile(mypath):            if mypath.find(xun) != -1:                print('找到文件',x)                print('路径',mypath)        else:            finpath(mypath)finpath(path)

import os

path= input('输入查询路径:')

xun=input('请输入要查询的文件包含的字符串:')

def finpath(path):

    for x in os.listdir(path):

        mypath=os.path.abspath(os.path.join(path,x))

        if os.path.isfile(mypath):

            if mypath.find(xun) != -1:

                print('找到文件',x)

                print('路径',mypath)

        else:

            finpath(mypath)

finpath(path)


  • 1

Reply