%s与%r的区别:
%r对应的是python的repr函数
print "%r" % s 等于 print repr(s)
- print "%s" % s 等于 print str(s)%
# %s ⇒ str(),比较智能;
# %r ⇒ repr(),处理较为简单和直接;
>> s
=
'world'
>>
print
(
'hello %s'
%
s)
hello world
>>
print
(
'hello %r'
%
s)
hello
'world'
>>
str
(s)
'world'
>>
repr
(s)
"'world'"