1 # !/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 # li = ["电脑","U盘","鼠标","游艇"] 4 # for item in li: 5 # print(item) 6 # input = input("请输入商品:") 7 8 #enumrate自动生成一列,默认0 自增1 9 #字符串 =》数字 int(字符串) 10 li = ["电脑","U盘","鼠标","游艇"] 11 for key,item in enumerate(li,1): 12 print(key,item) 13 inp = input("请输入商品:") 14 15 inp_num = int(inp) 16 print(li[inp_num-1])
时间: 2024-10-10 07:29:40