标签:value 索引 ack mac lis mes sha dex 列表
#names里面有3个2,返回第2个2的索引值
names=["Alex","jack","peiqi",2,"rain","mack",2,"racheal","shanshan",2,"longting"]
first_index=names.index(2) #第一个2的索引
print(first_index)
new_list=names[first_index+1:] #切片一个新列表
second_index=new_list.index(2) #取新列表里2的索引
print(second_index)
second_val=names[first_index+second_index+1] #
#print(new_list,first_index,second_index)
print("second_values:",second_val)
标签:value 索引 ack mac lis mes sha dex 列表
原文地址:https://www.cnblogs.com/chenjiao0904/p/9689923.html