python获取指定文件夹下的文件路径

#!/usr/bin/python
# -*- coding: UTF-8 -*-
# @date: 2018/1/6 23:08
# @name: tmp2
# @author:vickey-wu

import os
import re


def print_all_file_path(init_file_path, keyword):
for cur_dir, sub_dir, included_file in os.walk(init_file_path):
if included_file:
for file in included_file:
if re.search(keyword, file):
print(cur_dir + "\" + file)


def main():
print_all_file_path("E:pythonProcessDataAnalysis", ".py")


if __name__ == '__main__':
main()
原文地址:https://www.cnblogs.com/vickey-wu/p/8227519.html