Skip to content

Instantly share code, notes, and snippets.

@yeyuguo
Created April 4, 2016 12:02
Show Gist options
  • Save yeyuguo/c32eda65eec83b03f6304cd0cb0d000e to your computer and use it in GitHub Desktop.
Save yeyuguo/c32eda65eec83b03f6304cd0cb0d000e to your computer and use it in GitHub Desktop.
def search_file(search_dir='/',file=None):
if file is None:
result = search_dir
return result
else:
for i in os.listdir(search_dir):
path_file = os.path.join(search_dir,i)
if os.path.isfile(path_file):
if i == file:
result = path_file
print path_file
return result
else:
search_file(search_dir=path_file,file=file)
@yeyuguo
Copy link
Author

yeyuguo commented Apr 4, 2016

write this code for search one file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment