新手学python-笨方法学python-ex9-打印打印打印

跟着个教程学习,边学边做习题边记录。

新手学python-笨方法学python-ex9-打印打印打印 - 学习记录

跟着课程练习:

[root@lc test]# vi ex9.py 

# Here's some new strange stuff, remember bype it exactly.

days = "Mon Tue Wed The Fri Sat Sun"
months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug"

print "Here are the days: ", days
print "Here are the months: ", months

print """
There's something going on here.
With the three double-quotes.
We'll be able to type as much as we like.
Even 4 lines if we want, or 5, or 6.
"""
"ex9.py" 14L, 377C written
[root@lc test]# 


执行该程序

[root@lc test]# python ex9.py 
Here are the days:  Mon Tue Wed The Fri Sat Sun
Here are the months:  Jan
Feb
Mar
Apr
May
Jun
Jul
Aug

There's something going on here.
With the three double-quotes.
We'll be able to type as much as we like.
Even 4 lines if we want, or 5, or 6.

[root@lc test]# 


Three double-quotes可以打印多行,\n是换行。

至此,笨方法学-ex9-打印打印打印这一小节的学习结束了。

Wednesday, October 28, 2015 | Python

文章评论

No comments posted yet.

发表评论

Please add 5 and 8 and type the answer here: