Last active
October 14, 2017 00:48
-
-
Save heimoshuiyu/d0ee5a8ccf0067a1507f4d00b2028a3d to your computer and use it in GitHub Desktop.
walk_file_function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, os.path | |
def do_dir(file): #What you want to do with the file | |
pass | |
def do_file(file): #What you want to do with the | |
pass | |
def walk(where): #Walk file and dir in where | |
for localtion,dirlist,filelist in os.walk(where): | |
if dirlist: | |
for dirname in dirlist: | |
do_dir(os.path.join(localtion,dirname)) | |
if filelist: | |
for filename in filelist: | |
do_file(os.path.join(localtion,filename)) | |
if __name__ == '__main__': | |
walk(os.getcwd()) #Walk in where the workdir |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment