【发布时间】:2013-01-25 01:09:07
【问题描述】:
我想知道如果我有一本字典并且只想打印出特定键的值,我在 Python 中会做什么。
它将在一个变量中以及在:
dict = {'Lemonade':["1", "45", "87"], 'Coke:["23", "9", "23"] 'Water':["98", "2", "127"}
inp = input("Select key to print value for!" + "/r>>> ")
if inp in dict:
#Here is where I would like it to print the Value list for the key that is entered.
我正在运行 Python 3.3
【问题讨论】:
-
第一步是要有一个有效的字典对象。
-
道歉。没有那个意图。
标签: python dictionary python-3.x