I have rows like the following in a plain text file:
181006\td3a8d0236\tNicol\xc3\xa1s\tPe\xc3\xb1a\tmisc.person@email.com
I'd like to open and read the file using Python, then print out each line in its decoded form:
181006 d3a8d0236 Nicolás Peña misc.person@email.com
As a literal string this is pretty easy...
import codecs
a = b'181006\t000d3a8d0236\tNicol\xc3\xa1s\tPe\xc3\xb1a\tmisc.person@email.com'
b = codecs.decode(a)
print(b)
However, try as I may, I can't seem to find the b'' literal syntax equivalent for data in a variable. There are multiple SO posts about this, but I've had no luck using open()/read()/write() etc. Can someone offer a suggestion?