En Tue, 29 Jul 2008 10:08:21 -0300, Victor Subervi <[EMAIL PROTECTED]> escribi�:

Hi;
I have this code:
def a():
chars = ['\\i0', '\\u0', '\\qc', '\\b0', '\\ql', '\\i', '\\u', '\\b',
'\\yz']
rtf_markup = 'viewkind4\uc1\pard\nowidctlpar\qc\i\f0\fs36 Who is like the
Beast? Who can wage war against him?\par'

The \ is an escape character inside string literals. '\n' contains a *single* character and it's the same as chr(10). '\f0' is two characters long, not three. You have two alternatives:

a) double each \ (because \\ is interpreted as a single backslash):
rtf_markup = 'viewkind4\\uc1\\pard\\nowidctlpar\\qc...'

b) use raw strings - that is, prefix each string literal with a small r:
rtf_markup = r'viewkind4\uc1\pard\nowidctlpar...'

See the tutorial http://docs.python.org/tut/node5.html#SECTION005120000000000000000 and the gory details at http://docs.python.org/ref/strings.html

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list
  • RTF Parsing Victor Subervi
    • Re: RTF Parsing Gabriel Genellina

Reply via email to