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


Python plistlib.writePlistToBytes方法代码示例

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


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

示例1: writePlistToString

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import writePlistToBytes [as 别名]
def writePlistToString(rootObject, binary=True):
    if not binary:
        rootObject = wrapDataObject(rootObject, binary)
        if hasattr(plistlib, "dumps"):
            return plistlib.dumps(rootObject)
        elif hasattr(plistlib, "writePlistToBytes"):
            return plistlib.writePlistToBytes(rootObject)
        else:
            return plistlib.writePlistToString(rootObject)
    else:
        ioObject = io.BytesIO()
        writer = PlistWriter(ioObject)
        writer.writeRoot(rootObject)
        return ioObject.getvalue() 
开发者ID:NetEaseGame,项目名称:iOS-private-api-checker,代码行数:16,代码来源:__init__.py

示例2: test_bytes_deprecated

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import writePlistToBytes [as 别名]
def test_bytes_deprecated(self):
        pl = {
            'key': 42,
            'sub': {
                'key': 9,
                'alt': 'value',
                'data': b'buffer',
            }
        }
        with self.assertWarns(DeprecationWarning):
            data = plistlib.writePlistToBytes(pl)

        with self.assertWarns(DeprecationWarning):
            pl2 = plistlib.readPlistFromBytes(data)

        self.assertIsInstance(pl2, plistlib._InternalDict)
        self.assertEqual(pl2, plistlib._InternalDict(
            key=42,
            sub=plistlib._InternalDict(
                key=9,
                alt='value',
                data=plistlib.Data(b'buffer'),
            )
        ))

        with self.assertWarns(DeprecationWarning):
            data2 = plistlib.writePlistToBytes(pl2)
        self.assertEqual(data, data2) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:30,代码来源:test_plistlib.py

示例3: test_bytes_deprecated

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import writePlistToBytes [as 别名]
def test_bytes_deprecated(self):
        pl = {
            'key': 42,
            'sub': {
                'key': 9,
                'alt': 'value',
                'data': b'buffer',
            }
        }
        with self.assertWarns(DeprecationWarning):
            data = plistlib.writePlistToBytes(pl)

        with self.assertWarns(DeprecationWarning):
            pl2 = plistlib.readPlistFromBytes(data)

        self.assertIsInstance(pl2, dict)
        self.assertEqual(pl2, dict(
            key=42,
            sub=dict(
                key=9,
                alt='value',
                data=plistlib.Data(b'buffer'),
            )
        ))

        with self.assertWarns(DeprecationWarning):
            data2 = plistlib.writePlistToBytes(pl2)
        self.assertEqual(data, data2) 
开发者ID:bkerler,项目名称:android_universal,代码行数:30,代码来源:test_plistlib.py


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