笨办法学Python(九)

习题 9: 打印,打印,打印

 

 1 # Here's some new strange stuff, remember type it exactly. 
 2 
 3 days = "Mon Tue Wed Thu Fri Sat Sun" 
 4 months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug" 
 5 
 6 print "Here are the days: ", days 
 7 print "Here are the months: ", months 
 8 
 9 print """ 
10 There's something going on here. 
11 With the three double-quotes. 
12 We'll be able to type as much as we like. 
13 Even 4 lines if we want, or 5, or 6. 
14 """
View Code

你应该看到的结果:

 

 

加分习题

  1. 自己检查结果,记录你犯过的错误,并且在下个练习中尽量不犯同样的错误。

 

习题练习

    代码中:\n 表示回车换行,此处\n后若加空格,则换行字符也会空出一格,显示如下: 

 

 

反斜杠 “\” 是转义字符,即改变后面字符的含义。此符号可以连接行,也可输出带有格式的字符,比如想要输出 \n 则 \\n 即可

 三引号的主要作用是起到换行的作用。

参考:http://www.tuicool.com/articles/ymEvQ3

 

posted @ 2017-06-29 23:09  纟彖氵戋  阅读(184)  评论(0编辑  收藏  举报