nonunique string replacements
Steven D'Aprano
steven at REMOVE.THIS.cybersource.com.au
Wed Mar 3 03:42:01 EST 2010
On 2010年3月02日 23:06:13 -0800, Ben Racine wrote:
> All,
>> Say I have a string "l" ...
>> l = 'PBUSH 201005 K 1. 1. 1. 1. 1.
> 1.'
>> And I want to replace the first " 1." with a "500.2" and the second "
> 1." with " 5.2" ...
>> What pythonic means would you all recommend?
l = l.replace(" 1.", "500.2", 1)
l = l.replace(" 1.", "5.2", 1)
--
Steven
More information about the Python-list
mailing list