Suppose my txt file data.txt has the following content:
'\\|'
'//'
And I want to read the data.txt:
In [1]: with open('data.txt') as f:
...: data = f.readlines()
...:
In [2]: data
Out[2]: ["'\\\\|'\n", "'//'\n"]
In [3]: data[0]
Out[3]: "'\\\\|'\n"
And I want to
In [4]: ' '.join(data)
Out[4]: "'\\\\|' '//'"
But Python double read the \
. And the expected output is:
In [2]: data
Out[2]: ["'\\|'\n", "'//'\n"]
How can I get the expected output in a more efficient and pythonic way?