Discuss / Python / 打卡

打卡

Topic source

°Destiny

#1 Created at ... [Delete] [Delete and Lock User]
def find(s, name):

    d = [x for x in os.listdir(s) if os.path.isdir(os.path.join(s, x))]

    f = [x for x in os.listdir(s) if os.path.isfile(os.path.join(s, x)) and name in os.path.splitext(x)[1]]

    for x in f:

        print(os.path.join(s, x))

    for x in d:

        g = os.path.join(s, x)
        
             find(g, name)

°Destiny

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

更正,上面find(g,name)不应该缩进

def find(s, name):

    d = [x for x in os.listdir(s) if os.path.isdir(os.path.join(s, x))]

    f = [x for x in os.listdir(s) if os.path.isfile(os.path.join(s, x)) and name in os.path.splitext(x)[1]]

    for x in f:

        print(os.path.join(s, x))

    for x in d:

        g = os.path.join(s, x)
        
        find(g, name)

INT_MAX

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

每天都看见你打卡,很勤奋


  • 1

Reply