MRAB wrote: > You're almost there: > > re.subn('\x61','b','aaaa') > > or better yet: > > re.subn(r'\x61','b','aaaa') Wouldn't that becomes a literal \x61 instead of "a" as it is inside raw string?