序列
序列(consequence)是 python 中一种数据结构,这种数据结构根据索引来获取序列中的对象。
python 中含有六种内建序列类:list, tuple, string, unicode, buffer, xrange。其中 xrange 比较特殊,它是一个生成器,其他几个类型具有的一些序列特性对它并不适合。
一般说来,具有序列结构的数据类型都可以使用:index, len, max, min, in, +, *, 切片。如:
>>> a = 'Iloveyou'
>>> len(a)
8
>>> max(a)
'y'
>>> min(a)
'I'
>>> bool('o' in a)
True
>>> a + a
'Il......
阅读全文