本文整理汇总了Python中munch.Munch.foo方法的典型用法代码示例。如果您正苦于以下问题:Python Munch.foo方法的具体用法?Python Munch.foo怎么用?Python Munch.foo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类munch.Munch
的用法示例。
在下文中一共展示了Munch.foo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_base
# 需要导入模块: from munch import Munch [as 别名]
# 或者: from munch.Munch import foo [as 别名]
def test_base():
b = Munch()
b.hello = 'world'
assert b.hello == 'world'
b['hello'] += "!"
assert b.hello == 'world!'
b.foo = Munch(lol=True)
assert b.foo.lol is True
assert b.foo is b['foo']
assert sorted(b.keys()) == ['foo', 'hello']
b.update({'ponies': 'are pretty!'}, hello=42)
assert b == Munch({'ponies': 'are pretty!', 'foo': Munch({'lol': True}), 'hello': 42})
assert sorted([(k, b[k]) for k in b]) == [('foo', Munch({'lol': True})), ('hello', 42), ('ponies', 'are pretty!')]
assert "The {knights} who say {ni}!".format(**Munch(knights='lolcats', ni='can haz')) == 'The lolcats who say can haz!'
示例2: test_base
# 需要导入模块: from munch import Munch [as 别名]
# 或者: from munch.Munch import foo [as 别名]
def test_base():
b = Munch()
b.hello = "world"
assert b.hello == "world"
b["hello"] += "!"
assert b.hello == "world!"
b.foo = Munch(lol=True)
assert b.foo.lol is True
assert b.foo is b["foo"]
assert sorted(b.keys()) == ["foo", "hello"]
b.update({"ponies": "are pretty!"}, hello=42)
assert b == Munch({"ponies": "are pretty!", "foo": Munch({"lol": True}), "hello": 42})
assert sorted([(k, b[k]) for k in b]) == [("foo", Munch({"lol": True})), ("hello", 42), ("ponies", "are pretty!")]
assert (
"The {knights} who say {ni}!".format(**Munch(knights="lolcats", ni="can haz")) == "The lolcats who say can haz!"
)