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

python 序列

时间:2015-07-20 01:10:32      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:

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

 

python 序列

标签:

原文地址:http://www.cnblogs.com/shetunxiang/p/4660205.html

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