How to insert in a string @ a index
Zentrader
zentraders at gmail.com
Sat Sep 8 17:47:20 EDT 2007
More information about the Python-list mailing list
Sat Sep 8 17:47:20 EDT 2007
- Previous message (by thread): How to insert in a string @ a index
- Next message (by thread): How to insert in a string @ a index
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Same solution as above, but if you just want "Hello" and to not include words containing "Hello", i.e. "Helloing" or "Unhello", then you want to include a leading and/or trailing space. lit=" hello" ## note added space t1="nothello world hello. hello \nwhy world hello" start = t1.find(lit) t2 = t1[:start+1] + " XYZ" + t1[start+1:] print "t1 =", t1 print "t2 =", t2 start = t2.rfind(lit) t3 = t2[:start+1] + " XYZ" + t2[start+1:] print "t3 =", t3
- Previous message (by thread): How to insert in a string @ a index
- Next message (by thread): How to insert in a string @ a index
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list