python获取列表中指定元素在列表(或字符串)中的位置(索引)方法总结 一、。find()注意:只适用于字符串(只能返回第一次出现的字符索引!!!)stevenHelloword获取0的索引并打印asteven。find(o)print(a) 二、。index()注意:字符串和列表均能使用(只能返回第一次出现的字符索引!!!) 1、字符串stevenHelloword获取0的索引并打印asteven。index(o)print(a) 2、列表steven〔H,e,l,l,o,w,o,r,d〕获取0的索引并打印asteven。index(o)print(a) 三、re。finditer()注意:这个可以返回字符串中多个重复字符的索引 需要引用正则表达式模块importrestevenHelloword获取0的索引并打印a〔i。start()foriinre。finditer(o,steven)〕print(a)