当前位置: 首页>>代码示例>>Python>>正文


Python Munch.keys方法代码示例

本文整理汇总了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
开发者ID:thinker3,项目名称:py_learn,代码行数:17,代码来源:munch_learn.py

示例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)
开发者ID:xguse,项目名称:crunchers,代码行数:14,代码来源:plotting.py

示例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!'
开发者ID:Infinidat,项目名称:munch,代码行数:20,代码来源:test_munch.py

示例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!"
    )
开发者ID:mbarrien,项目名称:munch,代码行数:22,代码来源:test_munch.py


注:本文中的munch.Munch.keys方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。