本文整理汇总了Python中munch.Munch.keys方法的典型用法代码示例。如果您正苦于以下问题:Python Munch.keys方法的具体用法?Python Munch.keys怎么用?Python Munch.keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类munch.Munch
的用法示例。
在下文中一共展示了Munch.keys方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
# 需要导入模块: from munch import Munch [as 别名]
# 或者: from munch.Munch import keys [as 别名]
def test():
data = {
'a': 1,
'b': 2,
}
obj = Munch(**data)
assert isinstance(obj, dict)
for k, v in obj.iteritems():
print k, v
print obj.keys()
print obj.values()
assert obj.a == 1
obj.update(b=-2)
data = dict(**obj)
assert data['b'] == -2
示例2: group_med_line
# 需要导入模块: from munch import Munch [as 别名]
# 或者: from munch.Munch import keys [as 别名]
def group_med_line(x, y, **kwargs):
opts = Munch(kwargs)
y.index = x.values
data = pd.DataFrame(y)
meds = dict(data.reset_index().groupby('index').agg(np.median).iloc[:,0])
if 'colors' not in opts.keys():
opts.colors = {name: 'k' for name in meds.keys()}
for name, val in meds.items():
plt.axhline(y=val, linewidth=2, color=opts.colors[name], ls='solid', label=name, alpha=1)
示例3: test_base
# 需要导入模块: from munch import Munch [as 别名]
# 或者: from munch.Munch import keys [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!'
示例4: test_base
# 需要导入模块: from munch import Munch [as 别名]
# 或者: from munch.Munch import keys [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!"
)