[Numpy-discussion] string replace
Siegfried Gonzi
siegfried.gonzi at ed.ac.uk
Sun Apr 20 11:25:18 EDT 2014
Hi all
I know this is not numpy related but a colleague insists the following
is supposed to work. But it doesn't:
==
line_left = './erfo/restart.ST010.EN0001-EN0090.YYYYMMDDhh'
enafix = 'ST000.EN0001-EN0092'
line_left = line_left.replace('STYYY.ENXXXX-ENXXXX', enafix)
print 'line_left',line_left
==
[right answer would be: ./erfo/restart.ST000.EN0001-EN0092.YYYYMMDDhh' ]
I think it works in Fortran but not in Python. What would be the easiest
way to replacing this kind of pattern in a variable lenght string?
Thanks,
Siegfried
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
More information about the NumPy-Discussion
mailing list