formatter = "%r %r %r %r"
print formatter % (1, 2, 3, 4)
print formatter % ("one", "two", "three", "four")
print formatter % (True, False, False, True)
print formatter % (formatter, formatter, formatter, formatter)
print formatter % (
"I had this thing.",
"That you could type up right.",
"But it didn't sing.",
"So I said goodnight."
)
1 2 3 4 'one' 'two' 'three' 'four' True False False True '%r %r %r %r' '%r %r %r %r' '%r %r %r %r' '%r %r %r %r' 'I had this thing.' 'That you could type up right.' "But it didn't sing." 'So I said goodnight.'
%r
输出数据的原始表示, 比如:
print '%r' % '萌'
print '%s' % '萌'
'\xe8\x90\x8c' 萌
print '\xe8\x90\x8c'
萌
数据的原始表示并不唯一, 比如'moe'
和"moe"
, '萌'
和'\xe8\x90\x8c'
.