I'm reading a line from a file, which represents a string.
I.E reading from file: \'\\000\\000\\000\\000\'
.
When printing the text from the file, python prints \'\\000\\000\\000\\000\'
(without considering the \ etc.).
But when writing this text explicitly on the code and then printing it, python prints '\000\000\000\000'
(as expected).
I want to convert the string from the file to be treated as if it was explicitly written in the code (I'm not sure about the definitions). I tried to decode it but it changes the text entirely (adds few more slashes etc.)
with open('f.txt', 'r') as f:
line = f.readline() # line is written on the file \'\\000\\000\\000\\000\'
print(line) # prints \'\\000\\000\\000\\000\'
explicit_line = "\'\\000\\000\\000\\000\'"
print(explicit_line) # prints '\000\000\000\000'
# I would like print(line) to print the same content as print(explicit_line)
Any ideas? Thanks!