This sample code prints the representation of a line from a file. It allows its contents to be viewed, including control characters like '\n'
, on a single line—so we refer to it as the "raw" output of the line.
print("%r" % (self.f.readline()))
The output, however, appears with '
characters added to each end which aren't in the file.
'line of content\n'
How to get rid of the single quotes around the output?
(Behavior is the same in both Python 2.7 and 3.6.)