🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# 习题 8: 打印,打印 <table class="highlighttable"><tbody><tr><td class="linenos"> <div class="linenodiv"> <pre> 1&#13; 2&#13; 3&#13; 4&#13; 5&#13; 6&#13; 7&#13; 8&#13; 9&#13; 10&#13; 11&#13; 12</pre> </div> </td> <td class="code"> <div class="highlight"> <pre>formatter = "%r %r %r %r"&#13; &#13; print formatter % (1, 2, 3, 4)&#13; print formatter % ("one", "two", "three", "four")&#13; print formatter % (True, False, False, True)&#13; print formatter % (formatter, formatter, formatter, formatter)&#13; print formatter % (&#13; "I had this thing.",&#13; "That you could type up right.",&#13; "But it didn't sing.",&#13; "So I said goodnight."&#13; )&#13; </pre> </div> </td> </tr></tbody></table> ### 你应该看到的结果 ~~~ $ python ex8.py 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.' $ ~~~ ### 加分习题 1. 自己检查结果,记录你犯过的错误,并且在下个练习中尽量不犯同样的错误。 1. 注意最后一行程序中既有单引号又有双引号,你觉得它是如何工作的?