【发布时间】:2017-07-15 21:13:08
【问题描述】:
这是我的代码:
rootdir_path_without_slash = '/home/winpc/Downloads/Prageeth/backups/Final/node-wen-app'
rootdir_path_with_slash= '/home/winpc/Downloads/Prageeth/backups/Final/node-wen-app/'
dir_src = (rootdir_path_with_slash)
for subdir, dirs, files in os.walk(rootdir_path_without_slash):
for file in files:
file_name=os.path.join(subdir, file)
if file_name.endswith('.html'):
print file_name
这里的代码导航给定源目录中的所有子目录以搜索 .html 文件。如果找到节点模块文件夹,我需要跳过。请帮助我。
【问题讨论】:
-
只需在 for 循环中给出一个 if 条件,条件为 filename == 'node_modules': pass