Created
March 21, 2010 01:17
-
-
Save curiousstranger/339011 to your computer and use it in GitHub Desktop.
Search for a pattern in a file with 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
# Open file | |
f = open('test.txt', 'r') | |
# Feed the file text into findall(); it returns a list of all the found strings | |
strings = re.findall(r'some pattern', f.read()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment