new line

Kuljo kuljo at freemail.hu
Wed Aug 31 09:58:54 EDT 2005


Kuljo wrote:

> Kuljo wrote:
> 
>> Dear friends
>> I'm so sorry to bore you with this trivial problem. Allthou: I have
>> string having 0x0a as new line, but I should have \n instead.
>> How should I solve it?
>> I've tried
>>>>>text_new=tex_old.replace(str(0x0a), '\n')
>> and other things, but none of them worked.
>> Thanks in advance
> 
> 
> I have found this in the meantime:
> 
>>>>nl="\\"+"n"
>>>>text_new=replace(text_old, chr(10), nl)
> 
> It works.

Thanks Peter,
you are right, even
>>>text_new=replace(text_old, chr(10), "\\n")
works.
Yes, it was exactly what I needed. The problem actually was: I'm using Pilot
V for years and a part of my "knowledge base" is stored in den memo files.
On the PC side I'm using jpilot (Linux Kubuntu 5.04) which works perfectly.
Now I wanted to try out kontact (groupware). The shortcoming is that
kontact (actually kpilot in the background) does not import the memos. But
it store them in a folder as a file per memo. In this file are the cr/lf
indicated by hex 0a. The notes in kontact uses char \n instead. For this
translation I made a python script which works now.
Kind regards Kuljo



More information about the Python-list mailing list