码迷,mamicode.com
首页 > 编程语言 > 详细

python基础(字符串)

时间:2014-12-02 10:26:18      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   使用   sp   strong   on   div   

Python字符串:

在Python中的字符串被确定为一组连续的字符在引号之间, Python允许在任何对单引号或双引号。

串的子集,可以使用切片操作符可采用([]和[:]),索引从0开始的字符串的开始和结束(-1)。

加号(+)符号的字符串连接操作符,而星号(*)表示重复操作。

str = Hello,world!

print str
print str[0]
print str[2:5]
print str[2:]
print str * 2
print str + Ethon

产生以下结果:

bubuko.com,布布扣

 

python基础(字符串)

标签:style   blog   http   color   使用   sp   strong   on   div   

原文地址:http://www.cnblogs.com/wakey/p/4136719.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!