0

The double backslash here is causing me problems; how best can I avoid it?

data = ('\u200e中國哲學書電子化計劃', 'latin')
'{}'.format(data)
> "('\\u200e中國哲學書電子化計劃', 'latin')"
Emre
  • 5,976
  • 7
  • 29
  • 42
  • You are formatting a tuple. Don't do that; the contents of containers are *always* shown as `repr()` in that case. Format *contents*. – Martijn Pieters Nov 14 '16 at 20:31
  • See the section *"Container’s `__str__` uses contained objects’ `__repr__`"* in the first answer for an answer to this. – Dimitris Fasarakis Hilliard Nov 14 '16 at 20:36
  • Very good, this gets to the heart of the matter. Why does `__repr__` replace the single slash with a double slash in `'\u200e中國哲學書電子化計劃'.__repr__()` ? – Emre Nov 14 '16 at 20:59

0 Answers0