python学习笔记2:print的使用中的一些问题
2017-10-11 22:54
676 查看
本篇博文,总结一些在程序设计过程中使用print遇到的一些问题
1、使用print输出多个重复字符,我们可以使用如下程序
结果:..........
2、在print的结尾加入“,”可以续行,并产生空格
end1 = "C"
end1 = "C"
end2 = "h"
end3 = "e"
end4 = "e"
end5 = "s"
end6 = "e"
end7 = "B"
end8 = "u"
end9 = "r"
end10 = "g"
end11 = "e"
end12 = "r"
print end1 + end2 + end3 + end4 + end5 + end6,
print end7 + end8 + end9 + end10 + end11 + end12
结果:Cheese Burger
3、先看程序
print “%r %r %r %r” % (
"I had this thing.",
"That you could type up right.",
"But it didn't sing.",
"So I said good night."
)
结果:'I had this thing.' 'That you could type up right.' "But it didn't sing." 'So I said good night.'
解释:使用“%r”,系统会根据需要输出双引号或者单引号,不要太在意
4、先看程序
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.
"""
结果:
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.
解释:3引号中的内容会原样输出
原创性文章,转载请注明出处
CSDN:http://blog.csdn.net/qingwufeiyang12346。
1、使用print输出多个重复字符,我们可以使用如下程序
print "." * 10
结果:..........
2、在print的结尾加入“,”可以续行,并产生空格
end1 = "C"
end1 = "C"
end2 = "h"
end3 = "e"
end4 = "e"
end5 = "s"
end6 = "e"
end7 = "B"
end8 = "u"
end9 = "r"
end10 = "g"
end11 = "e"
end12 = "r"
print end1 + end2 + end3 + end4 + end5 + end6,
print end7 + end8 + end9 + end10 + end11 + end12
结果:Cheese Burger
3、先看程序
print “%r %r %r %r” % (
"I had this thing.",
"That you could type up right.",
"But it didn't sing.",
"So I said good night."
)
结果:'I had this thing.' 'That you could type up right.' "But it didn't sing." 'So I said good night.'
解释:使用“%r”,系统会根据需要输出双引号或者单引号,不要太在意
4、先看程序
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.
"""
结果:
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.
解释:3引号中的内容会原样输出
原创性文章,转载请注明出处
CSDN:http://blog.csdn.net/qingwufeiyang12346。
相关文章推荐
- Spring学习笔记(十八):使用jeesite时的一些问题总结
- 【笔记】struts2学习笔记(二)--常见问题/一些配置/Myeclipse使用
- python学习笔记1——python 中 Tkinder 使用常见问题
- cocos2d-x 学习笔记之Tiled Map地图使用时的一些问题
- Python学习总结笔记(5)--进程/线程Event机制使用时要注意的一个问题
- selenium学习笔记- selnium.RunScript(string script) 方法的使用 及有关自动化测试文本编辑器未解决的问题
- python2.6使用mysql包出现的一些问题以及解决办法
- CEGUI学习笔记 -- 使用CEGUI解决具体问题
- CEGUI学习笔记六-- 使用CEGUI解决具体问题
- 【XEN学习笔记】XEN 4.1.0 PVOPS设置和启动中遇到的一些问题
- python学习笔记:二维数组排序问题
- 我的嵌入式学习笔记(2)--scanf使用常见问题及解决方法
- SharePoint学习笔记001:访问站点列表碰到的一些问题
- 【PHP学习笔记】使用ZipArchive 创建zip包,总是不成功问题探究
- LifeRay Portal 6学习笔记7:Liferay的一些常见问题
- CEGUI学习笔记六-- 使用CEGUI解决具体问题
- Java写的手机计费系统(作为学习参考的实例:关键是Java类库里面的date和Calendar的使用和相互转换,以及一些日期的实际问题)
- mongoDB学习笔记3--python下使用
- [学习笔记]使用py2exe打包python程序
- Python学习笔记十二:列表(4)--len 、in、For的使用