标签:break log sort blog 元组 ever mat pass 逗号
print(i, end = ‘ ‘)
隔一个空格打印.
continue:终止本轮循环,开始下一轮循环
extend用于添加两个以上:
1 >>>member.extend([‘zzz‘,‘aaa‘]) 2 >>>member 3 [‘小甲鱼‘,‘小布丁‘,‘黑夜‘,‘迷途‘,‘怡静‘,‘福禄娃娃‘,‘zzz‘,‘aaa‘]
insert:
删除元素 (1) remove
1 member.remove(‘牡丹‘)
(2) del
(3) pop
分片
zip:
>>> a = [1,2,3,4,5,6,7,8] >>> b = [4,5,6,7,8] >>> zip(a,b) >>> list(zip(a,b)) [(1, 4), (2, 5), (3, 6), (4, 7), (5, 8)]
列表的拷贝
reverse:翻转列表
sort:对列表排序
元组 typle: 逗号是关键
>>>temp = (1,) >>>type(temp) <clsss ‘tuple‘>
>>>temp = 1,
format
>>>‘{0:.1f}{1}‘.format(27.658,‘GB‘) ‘27.7GB‘
sum
>>>tuple1 = (3,2,4) >>>sum(tuple1) 9
标签:break log sort blog 元组 ever mat pass 逗号
原文地址:http://www.cnblogs.com/1996zr/p/7688651.html