Python3的index()方法

index()函数用于从列表中找出某个值第一个匹配项的索引位置。 

list1 = ['Google', 'Runoob', 'Taobao']
print("Google的索引值:",list1.index("Google"))
print("Taobao的索引值:",list1.index("Taobao"))
# 输出:
Google的索引值: 0
Taobao的索引值: 2

猜你喜欢

转载自www.cnblogs.com/gepu1991/p/9108559.html