一、字符串
1.各种奇葩的内置方法
看方法,戳这儿。
2.格式化
就是按照统一的规格去输出字符串。
格式化字符: % 链接
字符串的格式化方法—format关键字
针对 format 有位置参数和关键字参数,例子分别如下:
>>> "{0} love {1}.{2}".format("I","fishC","com")
'I love fishC.com'
>>> "{a} love {b}.{c}".format(a="I",b="fishC",c="com")
'I love fishC.com'
>>>
二、序列
>>> numbers = [1,32,43,21,6,78,45,64,23,15]
>>> numbers
[1, 32, 43, 21, 6, 78, 45, 64, 23, 15]
>>> max(numbers)
78
>>> min(numbers)
1
>>> sum(numbers)
328
>>> sorted(numbers)
[1, 6, 15, 21, 23, 32, 43, 45, 64, 78]
>>> reversed(numbers)
<list_reverseiterator object at 0x0000000003315D68>
>>> list(reversed(numbers))
[15, 23, 64, 45, 78, 6, 21, 43, 32, 1]
>>> enumerate(numbers)
<enumerate object at 0x00000000036D8AF8>
>>> list(enumerate(numbers))
[(0, 1), (1, 32), (2, 43), (3, 21), (4, 6), (5, 78), (6, 45), (7, 64), (8, 23), (9, 15)]
>>>
>>> a = [1,2,3,4,5,6]
>>> b = [4,5,6,7]
>>> zip(a,b)
<zip object at 0x0000000003777208>
>>> list(zip(a,b))
[(1, 4), (2, 5), (3, 6), (4, 7)]
>>>
这几节课听了好久才听完,所以笔记写的也不好。。