美文网首页
笨办法学Python ex08

笨办法学Python ex08

作者: Joemini | 来源:发表于2016-12-10 19:28 被阅读0次

打印, 打印


  • 输入:
# -- coding: utf-8 --

formatter = "%r %r %r %r" # 将格式化字符串赋值给变量formatter

print formatter % (1,2,3,4) 
print formatter % ("one", "two", "three", "four") # 能将引号获取过来
print formatter % (True, False, False, True)
print formatter % (
    "I had this thing.",
    "That you could type up right.",
    "But it didn't sing.",
    "So I said goodnight."
) # 逗号使代码分行,实际打印出来的是在一行
  • 运行:

附加题

最后一行代码,打印出来既有单引号,又有双引号,至于原因暂时不知道,

相关文章

网友评论

      本文标题:笨办法学Python ex08

      本文链接:https://www.haomeiwen.com/subject/tadumttx.html