Peter Otten 在 2022年12月8日 星期四清晨5:17:59 [UTC+8] 的信中寫道:
> On 07/12/2022 03:23, Jach Feng wrote:
> > s0 = r'\x0a'
> > At this moment it was done by
> >
> > def to1byte(matchobj):
> > ....return chr(int('0x' + matchobj.group(1), 16))
> > s1 = re.sub(r'\\x([0-9a-fA-F]{2})', to1byte, s0)
> >
> > But, is it that difficult on doing this simple thing?
> >>> import codecs
> >>> codecs.decode(r"\x68\x65\x6c\x6c\x6f\x0a", "unicode-escape")
> 'hello\n'
Thank you. What I really want to handle is to any r'\xdd'. The r'\x0a' is for
example. Sorry, didn't describe it clearly:-)
--
https://mail.python.org/mailman/listinfo/python-list
- How to convert a raw string r'\xdd' to '\xdd' more gracef... Jach Feng
- Re: How to convert a raw string r'\xdd' to '\xdd' mo... MRAB
- Re: How to convert a raw string r'\xdd' to '\xdd' mo... Jach Feng
- Re: How to convert a raw string r'\xdd' to '\xdd... Roel Schroeven
- Re: How to convert a raw string r'\xdd' to '\xdd... Jach Feng
- Re: How to convert a raw string r'\xdd' to '\xdd' mo... Thomas Passin
- Re: How to convert a raw string r'\xdd' to '\xdd' mo... Jach Feng
- Re: How to convert a raw string r'\xdd' to '\xdd' mo... Peter Otten
- Re: How to convert a raw string r'\xdd' to '\xdd' mo... Jach Feng
- Re: How to convert a raw string r'\xdd' to '\xdd... Weatherby,Gerard
- Re: How to convert a raw string r'\xdd' to '... Thomas Passin
- Re: How to convert a raw string r'\xdd' to '\xdd... Peter Otten
- Re: How to convert a raw string r'\xdd' to '\xdd' mo... Jach Feng
- Re: How to convert a raw string r'\xdd' to '\xdd' mo... Jach Feng
- Re: How to convert a raw string r'\xdd' to '\xdd... Weatherby,Gerard
- Re: How to convert a raw string r'\xdd' to '\xdd... Jach Feng
- Re: How to convert a raw string r'\xdd' to '\xdd' mo... Jach Feng
