📌  相关文章
📜  替换列表中的多个元素 python - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:19.910000             🧑  作者: Mango

代码示例1
mapping = {
    '1': 'i',
    '2': 'put',
    '3': 'this',
    '4': 'here',
}
sentence = ['1', '2', '3', '4']
newsentence = [mapping.get(word, word) for word in sentence]
# ['I', 'put', 'this', 'here']