project_dir = 'D:/test/' # note: '/' in path# source = os.walk(project_dir)source = os.listdir(project_dir)fileExt = r".jpg"[print(_) for _ in source if _.endswith(fileExt)]
Ref: 策略評析 : 魚骨圖、因果圖與問題解決思考流程 - 科技產業資訊室(iKnow) (narl.org.tw)