>>> a=list('1123231132213')
>>> a
['1', '1', '2', '3', '2', '3', '1', '1', '3', '2', '2', '1', '3']
>>> a[3]='4'
>>> a
['1', '1', '2', '4', '2', '3', '1', '1', '3', '2', '2', '1', '3']
>>> a.index('3')
>>> a.append('5')
>>> a
['1', '1', '2', '4', '2', '3', '1', '1', '3', '2', '2', '1', '3', '5']
>>> a.pop(-3)
'1'
>>> a
['1', '1', '2', '4', '2', '3', '1', '1', '3', '2', '2', '3', '5']
>>> len(a)
>>> a.insert(1,'hello')
>>> a
['1', 'hello', '1', '2', '4', '2', '3', '1', '1', '3', '2', '2', '3', '5']
>>> dic={'张三':'1','李四':'5','王五':'11','林六':'17','何七':'25'}
>>> dic
{'张三': '1', '李四': '5', '王五': '11', '林六': '17', '何七': '25'}
>>> dic['潘二']='50'
>>> dic
{'张三': '1', '李四': '5', '王五': '11', '林六': '17', '何七': '25', '潘二': '50'}
>>> del(dic['潘二'])
>>> dic
{'张三': '1', '李四': '5', '王五': '11', '林六': '17', '何七': '25'}
>>> dic.values()
dict_values(['1', '5', '11', '17', '25'])
>>> dic.keys()
dict_keys(['张三', '李四', '王五', '林六', '何七'])
>>> dic.items()
dict_items([('张三', '1'), ('李四', '5'), ('王五', '11'), ('林六', '17'), ('何七', '25')])
>>> dic.get('李四')
'5'
>>> dic.pop('李四')
'5'
>>> dic
{'张三': '1', '王五': '11', '林六': '17', '何七': '25'}
>>> d={'09':'66','05':'80','14':'78','23':'90'}
>>> d['14']
'78'
>>> d.keys()
dict_keys(['09', '05', '14', '23'])
>>> d.values()
dict_values(['66', '80', '78', '90'])
>>> d.items()
dict_items([('09', '66'), ('05', '80'), ('14', '78'), ('23', '90')])
>>> d.get('05','66')
'80'
>>> d.pop('23','80')
'90'
>>> d
{'09': '66', '05': '80', '14': '78'}
>>> '04' in d
False
>>> '05'in d
True
>>> del(d['09'])
>>> d
{'05': '80', '14': '78'}>>> d["02"]="90"
>>> d{'05': '80', '14': '78', '02': '90'}
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。