import re def normalise_output(s): s = re.sub(r':\d{2,}', ':', s) s = re.sub(r'(at 0x)\w+', r'\1', s) s = s.replace('\\', '/') return s