📜  python 用字典替换 - Python 代码示例

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

代码示例1
address = "123 north anywhere street"

for word, initial in {"NORTH":"N", "SOUTH":"S" }.items():
    address = address.replace(word.lower(), initial)
print address