Reputation: 11469
I've a question about double quotes escaping in python string formatting. for example,
print "How tall are you?",
height = raw_input()
print "So you are %r tall" % height
when I put 5" 6' , it returns ' 5\'6" ' and i don't get why there is a backslash.
Upvotes: 0
Views: 1186
Reputation: 799420
You're asking for the representation of the string. Since the string contains both types of quotes, one type must be escaped in order for it to be a proper representation. If you only want what was typed then use %s
instead.
Upvotes: 5