1. 程式人生 > >Python基礎編程 學習筆記

Python基礎編程 學習筆記

string 自動 enume 調用 列表 strings dex rate 方法

在循環列表的同時記住列表的序列的一種方法

# 調用enumerate函數,這個函數可以叠代出索引-值對,其中索引是自動提供的
for index, string in enumerate(strings):
  if ‘xxx‘ in string:
    strings[index] = ‘[censored]‘

Python基礎編程 學習筆記