I have a regex substitution for the character -
, replacing it with »
. That all works just fine, however, when outputting the substituted result it is escaped. How do I properly print the characters upon output?
#!/usr/bin/python
# coding: utf-8
# -*- coding: utf-8 -*-
import os, sys
import re
searchText = "SKY ROCKETS IN FLIGHT - AFTERNOON DELIGHT"
result = re.sub("(\\-)", "»", searchText)
resultdecoded = result.decode('string_escape')
print("output:", resultdecoded)
('output:', 'SKY ROCKETS IN FLIGHT \xc2\xbb AFTERNOON DELIGHT')