1:双引号转义
<span style="font-size:18px;"><strong>print "he\"llo"</strong></span>只需要在双引号前面加一个反斜杠。
输出结果:he"llo
2:字符串的拼接
(1)可以用+号
<span style="font-size:18px;"><strong>print "hello" +" "+ "wolrd"</strong></span>
<span style="font-size:18px;"><strong>print "hello","world"</strong></span>
<span style="font-size:18px;"><strong>print "hello"*3</strong></span>
hello wolrd
hello world
hellohellohello
3:字符串长度
<span style="font-size:18px;"><strong>print len("hello")</strong></span>
4:类型转换:字符串转int
<span style="font-size:18px;"><strong>print int("111") + 1</strong></span>输出结果 112
5:类型转换:int转字符串
<span style="font-size:18px;"><strong>print "aaa" + str(1)</strong></span>
输出结果:aaa1
原文地址:http://blog.csdn.net/u013628152/article/details/43202069