重拾Python 八
来源:互联网 发布:2016电影采集网站源码 编辑:程序博客网 时间:2024/04/29 08:19
更多见识字符串格式化,见ex8.py:
#!/usr/bin/python# -*- coding: utf-8 -*-formatstr = "[%r][%r][%r][%r]"print formatstr % (1,2,3,4)print formatstr % ('one', 'two', 'three', 'four')print formatstr % (True, False, True, False)print formatstr % (formatstr, formatstr, formatstr, formatstr)print formatstr % ( "I am a stupid coder.", "I used to learn python.", "But I did not cherish it.", "Now I am aware of it." )
执行结果:
[1][2][3][4]['one']['two']['three']['four'][True][False][True][False]['[%r][%r][%r][%r]']['[%r][%r][%r][%r]']['[%r][%r][%r][%r]']['[%r][%r][%r][%r]']['I am a stupid coder.']['I used to learn python.']['But I did not cherish it.']['Now I am aware of it.']
格式化字符串中的占位符:
0 0
- 重拾Python 八
- 重拾Java(八)
- 重拾Python 一
- 重拾Python 二
- 重拾Python 三
- 重拾Python 四
- 重拾Python 五
- 重拾Python 六
- 重拾Python 七
- 重拾Python 九
- 重拾Python 十
- 重拾Python 十一
- 重拾Python 十二
- 重拾Python 十七
- 重拾Python 十八
- 重拾python 十九
- 重拾python 三十
- 重拾python 三十一
- 推进"五通一平":手淘技术"三大容器 五大方案"首次整体亮相 百川开放升级
- 用Delphi即时判断当前的网络的连接方式
- 【35.56%】【727A】Transformation: from A to B
- 数组操作函数
- MyEclipse+Tomcat+MAVEN+SVN项目完整环境搭建
- 重拾Python 八
- android极光推送】—从客户端到后台,一文通吃
- 字符串操作函数
- yuv
- [ 模板 ] 堆优化Dijkstra
- 牛客网-救援队
- 从文本文件中读取数据
- Date
- hdu 1398 Square Coins(母函数/完全背包)