On 24 Jul 2005 18:14:13 -0700, ncf <[EMAIL PROTECTED]> wrote:
>I know I've seen this somewhere before, but does anyone know what the
>function to escape a string is? (i.e., encoding newline to "\n" and a
>chr(254) to "\xfe") (and visa-versa)
>
>Thanks for helping my ignorance :P

    Python 2.4.1 (#2, Mar 30 2005, 21:51:10) 
    [GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> '\n\xfe'.encode('string-escape')
    '\\n\\xfe'
    >>> '\\n\\xfe'.decode('string-escape')
    '\n\xfe'
    >>> 

  Introduced in Python 2.3

  Jp
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to