Python基础编程 学习笔记

 在循环列表的同时记住列表的序列的一种方法

# 调用enumerate函数,这个函数可以迭代出索引-值对,其中索引是自动提供的
for index, string in enumerate(strings):
  if 'xxx' in string:
    strings[index] = '[censored]'

猜你喜欢

转载自www.cnblogs.com/JokerWu/p/9038807.html
今日推荐