itemdetails = {101: { 'Item Name':'Tshirt', 'Price':150.00, 'Stock':20},
102: { 'Item Name':'Shirt', 'Price':300.00, 'Stock':20},
103: { 'Item Name':'Shorts', 'Price':450.00, 'Stock':20},
104: { 'Item Name':'Trousers', 'Price':750.00, 'Stock':20}}
option = str(input("Press [C] for Item Code , [N] for Item Name: "))
if option=='n':
itemname=(input("Enter Item name: "))
print(itemdetails[itemname]) #====> how to access ???
else:
itemcode=int(input("Enter Item code: "))
print(itemdetails[itemcode])
#当我输入 itemname 时,我希望它列出该特定项目名称的整个子词典,例如,如果我输入 Tshirt,我想输出 =====> 101: { 'Item Name':'Tshirt', '价格':150.00,'库存':20}
那可能吗?
繁星点点滴滴
翻过高山走不出你
浮云间
交互式爱情
相关分类