How to generate java .properties files in python

Arnaud Delobelle arnodel at gmail.com
Sun Dec 4 09:33:34 EST 2011


On 4 December 2011 10:22, Peter Otten <__peter__ at web.de> wrote:

> I found another one:
>
>>>> u"äöü ΦΧΨ".encode("latin1", "backslashreplace")
> '\xe4\xf6\xfc \\u03a6\\u03a7\\u03a8'

That's it!  I was hoping for a built-in solution and this is it. FTR,
the 'backslashreplace' argument tells the encoder to replace any
character that it can't encode with a backslash escape sequence.
Which is exactly what I needed, only I hadn't realised it.  Thanks!

-- 
Arnaud



More information about the Python-list mailing list