Created
May 4, 2016 19:58
-
-
Save taylanpince/755adf9a69f6d500461dc36baf67d63a to your computer and use it in GitHub Desktop.
Python read/write
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
f = open("doc.txt", "r+") | |
contents = f.read() | |
contents = contents.replace("word", "another") | |
f.seek(0) | |
f.write(contents) | |
f.truncate() | |
f.close() | |
print contents |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment