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


Python Properties.attributes方法代码示例

本文整理汇总了Python中properties.Properties.attributes方法的典型用法代码示例。如果您正苦于以下问题:Python Properties.attributes方法的具体用法?Python Properties.attributes怎么用?Python Properties.attributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在properties.Properties的用法示例。


在下文中一共展示了Properties.attributes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: print_properties

# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import attributes [as 别名]
def print_properties(prop):
    def pretty(value):
        if type(value) == int:
            return str(value)
        else:
            return "%.2f" % value
    ps = [pretty(getattr(prop, p)) for p in Properties.attributes()]
    return formatString % tuple([prop.name] + ps)
开发者ID:copton,项目名称:ocram,代码行数:10,代码来源:text.py

示例2: export_all_properties

# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import attributes [as 别名]
def export_all_properties(out, app, props):
    data = { }
    for prop in props:
        for measurement in Properties.attributes():
            key = (app, prop.name, measurement)
            assert not data.has_key(key)
            data[key] = getattr(prop, measurement)

    pickle.dump(data, out)
开发者ID:copton,项目名称:ocram,代码行数:11,代码来源:text.py

示例3: tuple

# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import attributes [as 别名]
import os
import sys
import pickle
from properties import Properties

formatString = '%20s\t%7s\t%7s\t%7s\t%7s\t%7s\t%7s'

header = formatString % tuple([""] + Properties.attributes())

def print_properties(prop):
    def pretty(value):
        if type(value) == int:
            return str(value)
        else:
            return "%.2f" % value
    ps = [pretty(getattr(prop, p)) for p in Properties.attributes()]
    return formatString % tuple([prop.name] + ps)

def print_all_properties(out, props):
    out.write("# ")
    out.write("\n# ".join([header] + [print_properties(x) for x in props]))
    out.write("\n")

def export_all_properties(out, app, props):
    data = { }
    for prop in props:
        for measurement in Properties.attributes():
            key = (app, prop.name, measurement)
            assert not data.has_key(key)
            data[key] = getattr(prop, measurement)
开发者ID:copton,项目名称:ocram,代码行数:32,代码来源:text.py


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