Created
April 4, 2016 12:02
-
-
Save yeyuguo/c32eda65eec83b03f6304cd0cb0d000e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
write this code for search one file