以下内容基于python-v3.6
计算字典的长度
dict={'key1':'val1','key2':'val2','key3':'val3','key4':'val4','key5':'val5'}
l=len(dict)
print(l)
>> 5
以列表返回一个字典所有的键
#方法:radiansdict.keys()
dict={'key1':'val1','key2':'val2','key3':'val3','key4':'val4','key5':'val5'}
keys_list=dict.keys()
print(keys_list)
>> dict_keys(['key1', 'key2', 'key3', 'key4', 'key5'])
以列表返回字典中的所有值
#方法:radiansdict.values()
values_list=dict.values()
print(values_list)
>> dict_values(['val1', 'val2', 'val3', 'val4', 'val5'])