【发布时间】:2010-09-21 02:22:32
【问题描述】:
我有这个 python 字典“mydict”,包含数组,如下所示:
mydict = dict(
one=['foo', 'bar', 'foobar', 'barfoo', 'example'],
two=['bar', 'example', 'foobar'],
three=['foo', 'example'])
我想用“someotherword”替换所有出现的“example”。
虽然我已经想到了几种方法来做到这一点,但有没有最“pythonic”的方法来实现这一点?
【问题讨论】:
标签: python arrays dictionary replace