返回第一个值等于 x 的元素的下标,找不到时抛出 ValueError。
ValueError
x
整数下标
a = ["a", "b", "c", "b"] print(a.index("b")) print(a.index("b", 2))
1 3