Newbie question: string replace
usgog at yahoo.com
usgog at yahoo.com
Fri Oct 28 13:37:06 EDT 2005
Now it works:
rex = re.compile(r'(^.*username *=[^"]*")([^"]*)(".*$)')
for line in fileinput.input(FILE, inplace=1):
m = rex.match(line)
if m is not None:
line = "%s%s%s\n" % (m.group(1), new_name, m.group(3))
print line
But there is an extra line break after each line in FILE. Why is that?
I tried to line = "%s%s%s" % (m.group(1), new_name, m.group(3)) but it
turns out there are two extra line breaks after each line...
More information about the Python-list
mailing list