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


Python Object.serialize方法代码示例

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


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

示例1: serialize

# 需要导入模块: from object import Object [as 别名]
# 或者: from object.Object import serialize [as 别名]
    def serialize(self):
        """
        Convert Item to a string, suitable for saving to a file.
        """
        # Need to trim off the trailing bracket from the Object serialization.
        obj = Object.serialize(self)[:-1]

        if self.use_function is None:
            use_function = None
        else:
            use_function = self.use_function.__name__

        item = "'use_function':{0},}}".format(repr(use_function))

        return obj + item
开发者ID:aruse,项目名称:Bludgeon,代码行数:17,代码来源:item.py

示例2: serialize

# 需要导入模块: from object import Object [as 别名]
# 或者: from object.Object import serialize [as 别名]
    def serialize(self):
        """
        Convert Monster to a string, suitable for saving to a file.
        """
        # Need to trim off the trailing bracket from the Object serialization.
        obj = Object.serialize(self)[:-1]

        if self.ai is None:
            ai = None
        else:
            ai = repr(self.ai.__class__.__name__)

        inventory = repr([item.oid for item in self.inventory])
        mon = ("'hp':{0},'max_hp':{1},'mp':{2},'max_mp':{3},'ai':{4},"
               "'death':{5},'inventory':{6}}}".format(
                repr(self.hp), repr(self.max_hp), repr(self.mp),
                repr(self.max_mp), ai, repr(self.death.__name__), inventory))

        return obj + mon
开发者ID:aruse,项目名称:Bludgeon,代码行数:21,代码来源:monster.py


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