序列类型函数
len()#返回元素个数,
max()#最大字符(字典序)
min()#最小字符(字典序)
sum()#求和
reversed():#字典序排列
list():浅拷贝创建新列表
tuple():浅拷贝创建新元组
>>> s1=['name',"they're",'age','The','Ta']
>>> for t in reversed(s1):
print t
Ta
The
age
they're
name
>>> sorted(s1)
['Ta', 'The', 'age', 'name', "they're"]
enumerate()#序列号
>>> s=['age','number','name']
>>> for i,s in enumerate(s):
print i,s
0 age
1 number
2 name
zip()#组合
>>> help(zip)
Help on built-in function zip in module __builtin__:
zip(...)
zip(seq1 [, seq2 [...]]) -> [(seq1[0], seq2[0] ...), (...)]
Return a list of tuples, where each tuple contains the i-th element
from each of the argument sequences. The returned list is truncated
in length to the length of the shortest argument sequence.
>>> s=['name','age','number']
>>> s1=['Tim','555','123']
>>> for i,j in zip(s,s1):
print ('%s %s'%(i,j))
Name Tim
Age 555
Number 123