convert ascii escapes into binary form
hpj at urpla.net
Wed Jul 20 20:14:32 CEST 2005
Robert Kern wrote:
> Hans-Peter Jansen wrote:
>> Hi Pythonistas,
>> I need to convert ascii escapes into binary form, e.g.:
>> \f -> ^L
>> \033@\x1bk\000 -> ^[@^[k^@
>> (rvalues in terminal representation)
>> Any idea, how to do this most elegantly in python?
>> Do I really need to do a search n'replace orgy, combined with
>> regex for this task?
> In : s = '\\f'
> In : s.decode('string_escape')
> Out: '\x0c'
That did the trick, thanks a lot, Peter. Unfortunately, on the
target system, there's still python 2.0 running :-( Looks like
I've to bite the apple..
More information about the Python-list