Discuss / Python / 练习

练习

Topic source

松霜杨雪

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

import os

##### que_1 l = [x for x in os.listdir('.')] print(l)

##### que_2 def getFiles(findStr, path = '.'): l = [x for x in os.listdir(path)] for df in l: fpath = os.path.join(path, df) if os.path.isdir(df): getFiles(findStr,fpath) else: if df.find(findStr) != -1: print(fpath) getFiles('a')


  • 1

Reply