Created
August 20, 2011 22:31
-
-
Save kenkam/1159757 to your computer and use it in GitHub Desktop.
list comprehension
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
# i can haz python 2.6.6+ | |
with open('file.txt') as f: | |
lines = f.readlines() | |
for l in lines: | |
if 'safeChange' in l: | |
lines[lines.index(l)] = 'nyan nyan nyan' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment