首页 > IT职业 > IT职场 > 在Python中如何获取元素在数组中的索引号?
在Python中如何获取元素在数组中的索引号?

具体如下:
这里python是通过index方法获取索引号的
li = ['a', 'b', 'new', 'D', 'z', 'example', 'new', 'two', 'elements']
print li.index("example")
print li.index("new")
print li.index("z")
print "c" in li
运行结果如下:
5 2 4 False
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2530/viewspace-2837477/ ,如需转载,请注明出处,否则将追究法律责任。