On 2022-12-07 02:23, Jach Feng wrote:
s0 = r'\x0a' At this moment it was done bydef 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?
You could try this: >>> s0 = r'\x0a' >>> ast.literal_eval('"%s"' % s0) '\n' -- https://mail.python.org/mailman/listinfo/python-list