Discuss / Python / 作业-全部都是本章教的方法

作业-全部都是本章教的方法

Topic source

Airest1998

#1 Created at ... [Delete] [Delete and Lock User]
def findFile(p, kw):
    files = [x for x in os.listdir(p) if os.path.isfile(os.path.join(p, x)) and os.path.splitext(x)[1]==kw]
    for f in files:
        print('[p]', p, '\t[f]', f)
    dirs = [x for x in os.listdir(p) if os.path.isdir(os.path.join(p, x))]
    for d in dirs:
        d = os.path.join(p, d)
        findFile(d, kw)
    return
findFile('.', '.py')


这个简单


  • 1

Reply