names = ['金角大王', '黑姑娘', 'rain', 'eva', '狗蛋', '银角大王', 'eva'] first_index = names.index('eva') new_list = names[first_index+1:] second_index = new_list.index('eva') location = (first_index+second_index+1) names[location] = 'EVA' print(names) print(location)
通过index.()的方法找到第二个‘eva‘的值并将其改成‘EVA‘
最新推荐文章于 2022-05-21 13:22:33 发布