Python shows a literal string value, and uses escape codes in the console:
>>> x = '\x74\x65\x73\x74'
>>> x
'test'
>>> print(x)
test
How can I do the same when reading from a file?
$ cat test.txt
\x74\x65\x73\x74
$ cat test.py
with open('test.txt') as fd:
for line in fd:
line = line.strip()
print(line)
$ python3 test.py
\x74\x65\x73\x74