学习笔记-20150519
2015-05-20 07:36
78 查看
字符串的合并和占位符的使用
注意在%号前不能有引号。
# -*- coding:utf-8 -*- my_name ='中国' my_age =35 my_height =74 my_weight =180 my_teeth ='White' my_hair ='Brown' print("Let's talk about %s."% my_name) print("He's %d inch tall, %s"%(my_height, my_name)) #test注意 print("Let's add my height %d to my weight %d,and get the result: %d"%(my_height,my_weight,my_height+my_weight))
另一个例子:
x ="There are %d types of people"%10 binary ="binary" do_not ="don't" y="Those who know %s and those who %s."%(binary,do_not) print x print y print"I said:%r"%x print"I also said: '%s'."% y hilarious =False joke_evaluation ="Isn't that Joke so funny?! %r" print joke_evaluation %hilarious w="This is the left side of ..." e="a string with a right side." print w+e
运行结果:
There are 10 types of people
Those who know binary and those who don't.
I said:'There are 10 types of people'
I also said: 'Those who know binary and those who don't.'.
Isn't that Joke so funny?! False
This is the left side of ...a string with a right side.
附件列表
Image.png相关文章推荐
- maven 学习笔记(一)eclipse+android+maven
- 设计模式学习笔记
- java学习笔记08--泛型
- [python]-django学习笔记-[1]
- java学习笔记10
- 一、Jenkins学习笔记——Jenkins是啥么?
- python学习笔记(三)Unicode
- java学习笔记(11)
- Python学习笔记8:标准库之正则表达式
- 学习笔记之10-字符和字符串常用处理函数
- java视频学习笔记
- Android(java)学习笔记79:java中InetAddress类概述和使用
- css学习笔记一
- 设计模式学习笔记
- 每天学一点flash(60) Dictionary类学习笔记
- 用微软.NET架构企业解决方案 学习笔记(二)UML概要
- 我的OGRE学习笔记,在痤也要贴出来!
- C++Primer学习笔记之变量和基本类型
- [Swift]:快速学习笔记4 ARC和循环引用
- Android中Fragment学习笔记