Fwd: Request for solution

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue Dec 8 16:02:39 EST 2009


En Mon, 07 Dec 2009 21:59:42 -0300, 74yrs old <withblessings at gmail.com>  
escribió:

>> For Kannada project .txt(not .doc) is used, my requirement is to have
>> one space between two characters in Notepad file.  In MSword there is
>> provision to make space between two characters under "Font" and  can be
>> saved as _.doc_  But when tried to save as_ .txt_  all formatting will
>> disappear. I could not understand how to do in notepad. Even tried copy
>> and paste from doc to notepad but failed.
>>
>> In this context, I request you kindly for small Python program - to make
>> or insert space between two characters in the _text_ file. (I have
>> installed Fedora-11 and also ubuntu9.04)
>>
>> example: *F o r  K a n n a d a  p r o j e c t . t x t(n o t .d o c)  i
>> s  u s e d,  m y  r e q u i r e m e n t   i s  t o  h a v e  o n e  s p
>> a c e  b e t w e e n  t w o  c h a r a c t e r s  i n  t h e  t e x t.*

Suppose you have the desided text in a string:

py> txt = """For Kannada project .txt(not .doc) is used,
... my requirement is to have
... one space between two characters in Notepad file."""

You can insert one space between each caracter by using:

py> " ".join(txt)
'F o r   K a n n a d a   p r o j e c t   . t x t ( n o t   . d o c )   i  
s   u s
  e d ,   \n m y   r e q u i r e m e n t   i s   t o   h a v e \n o n e   s  
p a c
  e   b e t w e e n   t w o   c h a r a c t e r s   i n   N o t e p a d   f  
i l e
  .'

and then write the resulting text into a file as usual.

-- 
Gabriel Genellina




More information about the Python-list mailing list