tuple: 元组被定义后无法被修改
count():
1 #count(obj) 统计obj在元组中出现的次数 2 tup = (1,2,3,4,5,6,5,5,5,5,5,5,5) 3 print(tup.count(6))
len():
1 #len(tuple) 统计tuple的元素个数 2 tup = (1,2,3,4,5,6,7,8) 3 print(len(tup))
index():
1 #index(x,[start,[end]]) 返回x在tuple中第一次出现的索引 2 tup = (1,2,3,4,5,6,7,8) 3 x = tup.index(2)
dictionary: 字典里的键值对是无序的
1 dict = {1:'qq',2:'mm',3:'kk'} 2 #添加元素 3 dict[4] = 'yy' 4 #删除元素 5 del dict[1] 6 #修改元素 7 dict[2] = 'hh'