本文整理汇总了Python中msgpack.Unpacker.skip方法的典型用法代码示例。如果您正苦于以下问题:Python Unpacker.skip方法的具体用法?Python Unpacker.skip怎么用?Python Unpacker.skip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msgpack.Unpacker
的用法示例。
在下文中一共展示了Unpacker.skip方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_write_bytes
# 需要导入模块: from msgpack import Unpacker [as 别名]
# 或者: from msgpack.Unpacker import skip [as 别名]
def test_write_bytes():
unpacker = Unpacker()
unpacker.feed(b'abc')
f = six.BytesIO()
assert unpacker.unpack(f.write) == ord('a')
assert f.getvalue() == b'a'
f = six.BytesIO()
assert unpacker.skip(f.write) is None
assert f.getvalue() == b'b'
f = six.BytesIO()
assert unpacker.skip() is None
assert f.getvalue() == b''
示例2: test_foobar_skip
# 需要导入模块: from msgpack import Unpacker [as 别名]
# 或者: from msgpack.Unpacker import skip [as 别名]
def test_foobar_skip():
unpacker = Unpacker(read_size=3, use_list=1)
unpacker.feed(b"foobar")
assert unpacker.unpack() == ord(b"f")
unpacker.skip()
assert unpacker.unpack() == ord(b"o")
unpacker.skip()
assert unpacker.unpack() == ord(b"a")
unpacker.skip()
with raises(OutOfData):
unpacker.unpack()
示例3: test_foobar_skip
# 需要导入模块: from msgpack import Unpacker [as 别名]
# 或者: from msgpack.Unpacker import skip [as 别名]
def test_foobar_skip():
unpacker = Unpacker(read_size=3, use_list=1)
unpacker.feed(b'foobar')
assert unpacker.unpack() == ord(b'f')
unpacker.skip()
assert unpacker.unpack() == ord(b'o')
unpacker.skip()
assert unpacker.unpack() == ord(b'a')
unpacker.skip()
try:
o = unpacker.unpack()
assert 0, "should raise exception"
except StopIteration:
assert 1, "ok"