python 序列

python 序列

序列(sequence)是一组有顺序的对象的集合

 

N == 序列的长度 == len(sequence)

 

常用的序列有:字符串、列表、元组

1、序列类型操作符

成员关系操作符 (in, not in)

>>> a = 'ajdlks'
>>> print 'a' in a
True

2、连接操作符( + )

>>> s1 = 'boy'
>>> s2 = 'girl'
>>> print s1 + s2
boygirl
>>> print s1 + ' ' + 'and' + ' ' + s2
boy and girl

3、重复操作符 ( * )

>>> s = 'boy'
>>> print s * 5
boyboyboyboyboy

 

posted @ 2015-07-19 23:42  蛇吞象  阅读(154)  评论(0编辑  收藏  举报