Something like this might do the trick: import re f = open("file.txt") old_text = f.readlines() f.close() new_text = [re.sub(r'.\b', '', i) for i in old_text] f = open("file_modified.txt", "w") f.writelines(new_text)
I don't know how necessary the separate read and writes are, but it'll be good for a start. At any rate, you'll want to look at the re<http://docs.python.org/lib/module-re.html>module. On Thu, Jun 26, 2008 at 16:32, <[EMAIL PROTECTED]> wrote: > Hi > I am a beginner on Python and have a problem.. > > I have text file and reading it line by line and there are backspace > characters in it like '\b' or anything you want like "#". I want to > replace these chars. with Backspace action. I mean deleting the > previous char. and the \b char also. and writing all cleaned text to a > file again. > > How can I do that. > > Thanks.. > -- > http://mail.python.org/mailman/listinfo/python-list >
-- http://mail.python.org/mailman/listinfo/python-list