按照key排序(结果是list):
sortedDict = sorted(key_value)
按照value排序:
sortedDict = sorted(key_value.items(), key = lambda kv:(kv[1], kv[0]))
dict遍历
for key, value in aa.items():
print(key, value)
判断key是否在dict里面
for i in range(len(s)):
if s[i] not in removeCharDic:
s3 += s[i]
判断
调用函数一定要加上括号(),否则函数就没有被调用,只是引用函数而已.
aa = dict.fromkeys('abc', 0)
for key, value in aa.items():
print(key, value)