%r vs %s
ans1:
The %s specifier converts the object using str(), and %r converts it using repr().
For some objects such as integers, they yield the same result, but repr() is special in that (for types where this is possible) it conventionally returns a result that is valid Python syntax, which could be used to unambiguously recreate the object it represents.
Here's an example, using a date:
>>> import datetime
>>> d = datetime.date.today()
>>> str(d)
'2011-05-14'
>>> repr(d)
'datetime.date(2011, 5, 14)'
Types for which repr() doesn't produce Python syntax include those that point to external resources such as a file, which you can't guarantee to recreate in a different context.
ans2:
%r shows with quotes:
It will be like:
I said: 'There are 10 types of people.'.
If you had used %s it would have been:
I said: There are 10 types of people..
-only true for strings, other types have different behavior – Winston Ewert May 14 '11 at 22:51