[Tutor] string replacement

Chandrashekar mailchansek at yahoo.com
Mon May 21 09:56:59 CEST 2007


Hi,

I am trying to do something like this in python. Can you please help?

handle= open('test.txt','a')

handle.write('''

Testsomething$i

something$i-test

'''
)

when i write into the file, i would like to have the output like this.

Testsomething1
something1-test
Testsomething2
something2-test
Testsomething3
something3-test
.......

I can perform the same using a loop. But how do i append i (1,2,......n) while i am writing into the file.(I mean inside the handle.write)

Thanks,
Chandru

       
---------------------------------
Pinpoint customers who are looking for what you sell. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070521/d576a5df/attachment.html 


More information about the Tutor mailing list