chktype為限定的型別

lvbuff為buff及相關的條件

只有達成條件才讓取buff

程式碼

#coding:utf8
chktype = {'type':'rock','lan':'en'}
lvbuff = {'buff':{'a':1}, 'type':'rock', 'lan':'en'}

#條件符合了才提出buff
flag = 0
for chk in chktype.keys():
    if chk in lvbuff:
        print chk,'in lvbuff'
        flag +=1

l = len(chktype)
if flag == l:
    print 'can get buff'
    print lvbuff['buff']