版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/bq_cui/article/details/89921311
# -*- coding: utf-8 -*-
"""
Created on Tue May 7 14:34:41 2019
@author: Administrator
"""
d={'name':'老王', 'Gender':'男', '年龄':'21', '身高':'181'}
print(d)
item1 = [('city','长春'), ('renkou','500'), ('area','23'), ('posi','north'), ('weather','sunny')]
d1 = dict(item1)
print(d1)
print(len(d1))
#返回关联到某键的值
print(d1['city'])
#删除某键
del d1['renkou']
print(d1)
# 查找键
print('city' in d1)
print('aa' in d1)
运行:
{'name': '老王', 'Gender': '男', '年龄': '21', '身高': '181'}
{'city': '长春', 'renkou': '500', 'area': '23', 'posi': 'north', 'weather': 'sunny'}
5
长春
{'city': '长春', 'area': '23', 'posi': 'north', 'weather': 'sunny'}
True
False