2 yanlixin 2015 yanlixin_2015 于 2016.03.07 19:53 提问

python 出现dict' object has no attribute 'key'

def make_omelet(omelet_type):
def get_omelet_ingredients(omelet_name):
ingredients={"egg":2,"milk":1}
if omelet_name=="cheese":
ingredients["cheddar"]=2
elif omelet_name=="western":
ingredients["jack_cheese"]=2
ingredients["ham"]=1
ingredients["onion"]=1
elif omelet_name=="greek":
ingredients["feta_cheese"]=2
else:
print("that'not on the menu")
return None
return ingredients
if type(omelet_type)==type({}):
return make_food(omelet_type,"omelet")
elif type(omelet_type)==type(""):
omelet_ingredients = get_omelet_ingredients(omelet_type)
return make_food(omelet_ingredients,omelet_type)
else:
print("kdkdkdk%s"%omelet_type)

`>>>omelet_type=make_omelet("cheese")


1个回答

oyljerry
oyljerry   Ds   Rxr 2016.03.07 20:02

你的字典数据中有这个key的数据吗

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!