创建字典:
info = {
'stu1101': 'chenshengkuan',
'stu1102': 'luomin',
'stu1104': 'zeng',
'stu1103': 'liushunli',
}
查找:
print(info['stu1101'])
增加
info['stu1101'] = 'huang'
删除:
del info['stu1101']
info.pop('stu1101')
查找:
print(info.get('stu1111'))
print('stu1101' in info)
循环打印:
for i in info:
print(i,info[i])
较高效的:
for k,v in info.items():
print(k,v)