Python基础-枚举enumerate
将列表转化成枚举类型示例:
li =['电脑','手机','电视'] for key,item in enumerate(li): print(key,item) i = input("please input index:") index = int(i) print(li[index])
li =['电脑','手机','电视'] for key,item in enumerate(li): print(key,item) i = input("please input index:") index = int(i) print(li[index])