字符串
格式化
format方法
{}内代表要表示的字段
>>> "i {0} an apple.{1} ".format("have","com")
'i have an apple.com '
>>> "i {a} an apple.{b} ".format(a="have",b="com")
'i have an apple.com '
>>> '{0:.1f}{1}'.format(27.658,'AB')
'27.7AB'
%
>>> '%c'%99
'c'
序列
相关操作函数
>>> num = [1,2,4,6,8,9]
>>> sum(num)
30
>>> sum(num,6)
36
>>> enumerate(num)
<enumerate object at 0x0000024AB7BDF600>
>>> list(enumerate(num))
[(0, 1), (1, 2), (2, 4), (3, 6), (4, 8), (5, 9)]
>>> a = [1,3,5,7,9]
>>> b = [2,4,6,8,6,4,2]
>>> list(zip(a,b))
[(1, 2), (3, 4), (5, 6), (7, 8), (9, 6)]
主要是一些操作函数,以后用到的时候再查找