Created
December 6, 2016 06:18
-
-
Save jackyshan/5cee0dd18653f04e5edd8f2d94dc94c0 to your computer and use it in GitHub Desktop.
Python查找当前目录下文件的匹配内容
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
| import os | |
| for file in os.listdir(os.getcwd()): | |
| f = open(file) | |
| content = f.readline() | |
| while content: | |
| if 'xxx' in content : | |
| print content | |
| pass | |
| content = f.readline() | |
| pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment