I'm running Python on terminal
Given a string string = "abcd\n"
I'd like to print
it somehow so that the newline characters '\n'
in abcd\n
would be visible rather than go to the next line
Can I do this without having to modify the string and adding a double slash (\\n
)
Use repr
>>> string = "abcd\n" >>> print(repr(string)) 'abcd\n'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With