python中批量访问字典中指定键的值
>>> test1 = {"key1":"aa","key2":"bb","key3":"cc","key4":"dd","key5":"ee","key6":"ff","key7":"gg"}
>>> type(test1)
<class 'dict'>
>>> len(test1)
7
>>> for i in test1:
print(i)
key1
key2
key3
key4
key5
key6
key7
>>> keys=["key7","key4","key2"]
>>> for i in test1:
if i in keys:
print(i,test1[i])
key2 bb
key4 dd
key7 gg