字典
增
dict1 = {'one':1,'two':2,'three':3}
dict1
{'one': 1, 'two': 2, 'three': 3}
dict1['four']= "4"
dict1
{'one': 1, 'two': 2, 'three': 3, 'four': '4'}
删
del dict1['four']
dict1
{'one': 1, 'two': 2, 'three': 3}
改
dict1 = {'one':1,'two':2,'three':4}
dict1['three'] = 3
print(dict1)
{'one': 1, 'two': 2, 'three': 3}
查
print ("dict1['one']: ", dict1['one'])
dict1['one']: 1
元组
增
tup1 = (1,2,3)
tup1
(1, 2, 3)
tup2 = (4,5,6)
tup2
(4, 5, 6)
tup3 = tup1+tup2
tup3
(1, 2, 3, 4, 5, 6)
删
tup = (1,2,3,)
print (tup)
(1, 2, 3)
del tup
改
tup = (('one',1),('tow',2),['four',3])
tup[2][0] = 'three'
tup
(('one', 1), ('tow', 2), ['three', 3])
查
print(tup[2])
['three', 3]
集合
增
thisset = set(('1','2','3'))
thisset
{'1', '2', '3'}
thisset.add('4')
thisset
{'1', '2', '3', '4'}
删
thisset.remove('4')
thisset
{'1', '2', '3'}
改
thisset = set(('1','2','3'))
thisset.remove('3')
thisset.update('4')
thisset
{'1', '2', '4'}
查
for i in thisset:
print(i)
4
2
1