I apologize up front for the dumbness of this question, but I can't figure it out and its driving me crazy.
In ruby I can do:
irb(main):001:0> s = "\t\t\n"
=> "\t\t\n"
irb(main):003:0> puts s
=> nil
irb(main):004:0> puts s.inspect
"\t\t\n"
Is there an equivalent of ruby's inspect
function in python?
repr()
:
>>> print repr('\t\t\n')
'\t\t\n'
You can use repr or (backticks), I am doing the exactly the same things as you did above.
>>> s = "\t\t\n"
>>> s
'\t\t\n'
>>> print s
>>> repr(s)
"'\\t\\t\\n'"
>>> print repr(s)
'\t\t\n'
>>> print `s`
'\t\t\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