我想确定dict key的值处于以下哪种状态:
以下是我目前正在尝试的:
if item[itemTo] == 0:
print("You don't have a %s." % (itemTo))
elif item[itemTo] > 0:
print("You have %i of %s." % (item[itemTo]))
else:
print("%s doesn't exist." % (itemTo))
但是,当itemTo
不在item
dict中时,我在if item[itemTo] == 0:
行得到这个错误:
要更改测试顺序:
相关问题 更多 >
编程相关推荐