Hi,
So i want to replace multiple lines in a text file and I have reasoned
the best way to do this is with a dictionary. I have simplified my
example and broadly I get what I want however I am now printing my
replacement string and part of the original expression. I am guessing
that I will need
2011/4/5 Martin De Kauwe mdeka...@gmail.com:
Hi,
So i want to replace multiple lines in a text file and I have reasoned
the best way to do this is with a dictionary. I have simplified my
example and broadly I get what I want however I am now printing my
replacement string and part of the
How about creating a new string instead of replacing the original.
def replace_keys(text, replacements_dict):
text_list = text.split('\n')
new_text = ''
for line in text_list:
key=line.split('=')[0]
if key.strip() in replacements_dict:
new_text = new_text +
On Apr 5, 3:59 am, Martin De Kauwe mdeka...@gmail.com wrote:
Hi,
So i want to replace multiple lines in a text file and I have reasoned
the best way to do this is with a dictionary. I have simplified my
example and broadly I get what I want however I am now printing my
replacement string and
yes thanks both work nicely, I will ponder the suggestions.
--
http://mail.python.org/mailman/listinfo/python-list