• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.hexlify函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中thriftpy.utils.hexlify函数的典型用法代码示例。如果您正苦于以下问题:Python hexlify函数的具体用法?Python hexlify怎么用?Python hexlify使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_write_string

def test_write_string():
    b = TCyMemoryBuffer()
    proto.write_val(b, TType.STRING, "hello world!")
    b.flush()
    assert "00 00 00 0c 68 65 6c 6c 6f 20 77 6f 72 6c 64 21" == hexlify(b.getvalue())

    b = TCyMemoryBuffer()
    proto.write_val(b, TType.STRING, u("你好世界"))
    b.flush()
    assert "00 00 00 0c e4 bd a0 e5 a5 bd e4 b8 96 e7 95 8c" == hexlify(b.getvalue())
开发者ID:hand515,项目名称:thriftpy,代码行数:10,代码来源:test_protocol_cybinary.py


示例2: test_pack_string

def test_pack_string():
    b = BytesIO()
    proto.write_val(b, TType.STRING, "hello world!")
    assert_equal("00 00 00 0c 68 65 6c 6c 6f 20 77 6f 72 6c 64 21",
                 hexlify(b.getvalue()))

    b = BytesIO()
    proto.write_val(b, TType.STRING, u("你好世界"))
    assert_equal("00 00 00 0c e4 bd a0 e5 a5 bd e4 b8 96 e7 95 8c",
                 hexlify(b.getvalue()))
开发者ID:atbrox,项目名称:thriftpy,代码行数:10,代码来源:test_protocol_cybinary.py


示例3: test_pack_string

def test_pack_string():
    b, proto = gen_proto()
    proto.write_val(TType.STRING, "hello world!")
    assert "0c 68 65 6c 6c 6f 20 77 6f 72 6c 64 21" == \
           hexlify(b.getvalue())

    b1, proto1 = gen_proto()
    proto1.write_val(TType.STRING, "你好世界")
    assert "0c e4 bd a0 e5 a5 bd e4 b8 96 e7 95 8c" == \
           hexlify(b1.getvalue())
开发者ID:AllanDaemon,项目名称:thriftpy,代码行数:10,代码来源:test_protocol_compact.py


示例4: test_pack_container_bool

def test_pack_container_bool():
    b, proto = gen_proto()
    proto.write_val(TType.LIST, [True, False, True], TType.BOOL)
    assert "31 01 02 01" == hexlify(b.getvalue())

    b, proto = gen_proto()
    proto.write_val(TType.MAP, {"a": True}, (TType.STRING, TType.BOOL))
    assert "01 81 01 61 01" == hexlify(b.getvalue())

    b, proto = gen_proto()
    proto.write_val(TType.MAP, {"a": [True, False]},
                    (TType.STRING, (TType.LIST, TType.BOOL)))
    assert "01 89 01 61 21 01 02" == hexlify(b.getvalue())
开发者ID:AllanDaemon,项目名称:thriftpy,代码行数:13,代码来源:test_protocol_compact.py


示例5: test_pack_string

def test_pack_string():
    b = TMemoryBuffer()
    p = proto.TCyBinaryProtocol(b)
    p.write_val(TType.STRING, "hello world!")
    p.write_message_end()
    assert "00 00 00 0c 68 65 6c 6c 6f 20 77 6f 72 6c 64 21" == \
        hexlify(b.getvalue())

    b = TMemoryBuffer()
    p = proto.TCyBinaryProtocol(b)
    p.write_val(TType.STRING, u("你好世界"))
    p.write_message_end()
    assert "00 00 00 0c e4 bd a0 e5 a5 bd e4 b8 96 e7 95 8c" == \
        hexlify(b.getvalue())
开发者ID:lodevil,项目名称:thriftpy,代码行数:14,代码来源:test_protocol_cybinary.py


示例6: test_write_empty_struct

def test_write_empty_struct():
    b = TMemoryBuffer()
    item = TItem()
    p = proto.TCyBinaryProtocol(b)
    p.write_struct(item)
    p.write_message_end()
    assert "00" == hexlify(b.getvalue())
开发者ID:lodevil,项目名称:thriftpy,代码行数:7,代码来源:test_protocol_cybinary.py


示例7: test_write_message_begin

def test_write_message_begin():
    b = TMemoryBuffer()
    p = proto.TCyBinaryProtocol(b)
    p.write_message_begin("test", TType.STRING, 1)
    p.write_message_end()
    assert "80 01 00 0b 00 00 00 04 74 65 73 74 00 00 00 01" == \
        hexlify(b.getvalue())
开发者ID:lodevil,项目名称:thriftpy,代码行数:7,代码来源:test_protocol_cybinary.py


示例8: test_write_message_begin_no_strict

def test_write_message_begin_no_strict():
    trans = TCyMemoryBuffer()
    b = proto.TCyBinaryProtocol(trans, strict_write=False)
    b.write_message_begin("test", TType.STRING, 1)
    b.write_message_end()
    assert "00 00 00 04 74 65 73 74 0b 00 00 00 01" == \
        hexlify(trans.getvalue())
开发者ID:GuoJing,项目名称:thriftpy,代码行数:7,代码来源:test_protocol_cybinary.py


示例9: test_write_struct

def test_write_struct():
    b = BytesIO()
    item = TItem(id=123, phones=["123456", "abcdef"])
    proto.TBinaryProtocol(b).write_struct(item)
    assert ("08 00 01 00 00 00 7b 0f 00 02 0b 00 00 00 02 00 00 00 "
            "06 31 32 33 34 35 36 00 00 00 06 61 62 63 64 65 66 00") == \
        hexlify(b.getvalue())
开发者ID:AllanDaemon,项目名称:thriftpy,代码行数:7,代码来源:test_protocol_binary.py


示例10: test_write_struct

def test_write_struct():
    b = BytesIO()
    item = TItem(id=123, phones=['123456', 'abcdef'])
    proto.TCyBinaryProtocol(b).write_struct(item)
    assert_equal("08 00 01 00 00 00 7b 0f 00 02 0b 00 00 00 02 00 00 00 "
                 "06 31 32 33 34 35 36 00 00 00 06 61 62 63 64 65 66 00",
                 hexlify(b.getvalue()))
开发者ID:atbrox,项目名称:thriftpy,代码行数:7,代码来源:test_protocol_cybinary.py


示例11: test_write_i32

def test_write_i32():
    b = TMemoryBuffer()
    b = TCyBufferedTransport(b)
    proto.write_val(b, TType.I32, 1234567890)
    b.flush()

    assert "49 96 02 d2" == hexlify(b.getvalue())
开发者ID:lepture,项目名称:thriftpy,代码行数:7,代码来源:test_protocol_cybinary.py


示例12: test_write_i8

def test_write_i8():
    b = TMemoryBuffer()
    b = TCyBufferedTransport(b)
    proto.write_val(b, TType.I08, 123)
    b.flush()

    assert "7b" == hexlify(b.getvalue())
开发者ID:lepture,项目名称:thriftpy,代码行数:7,代码来源:test_protocol_cybinary.py


示例13: test_write_i16

def test_write_i16():
    b = TMemoryBuffer()
    b = TCyBufferedTransport(b)
    proto.write_val(b, TType.I16, 12345)
    b.flush()

    assert "30 39" == hexlify(b.getvalue())
开发者ID:lepture,项目名称:thriftpy,代码行数:7,代码来源:test_protocol_cybinary.py


示例14: test_write_empty_struct

def test_write_empty_struct():
    trans = TCyMemoryBuffer()
    b = proto.TCyBinaryProtocol(trans)
    item = TItem()
    b.write_struct(item)
    b.write_message_end()
    assert "00" == hexlify(trans.getvalue())
开发者ID:GuoJing,项目名称:thriftpy,代码行数:7,代码来源:test_protocol_cybinary.py


示例15: test_write_bool

def test_write_bool():
    b = TMemoryBuffer()
    b = TCyBufferedTransport(b)
    proto.write_val(b, TType.BOOL, 1)
    b.flush()

    assert "01" == hexlify(b.getvalue())
开发者ID:lepture,项目名称:thriftpy,代码行数:7,代码来源:test_protocol_cybinary.py


示例16: test_write_message_begin

def test_write_message_begin():
    b = TMemoryBuffer()
    trans = TCyBufferedTransport(b)
    b = proto.TCyBinaryProtocol(trans)
    b.write_message_begin("test", TType.STRING, 1)
    b.write_message_end()
    assert "80 01 00 0b 00 00 00 04 74 65 73 74 00 00 00 01" == \
        hexlify(trans.getvalue())
开发者ID:lepture,项目名称:thriftpy,代码行数:8,代码来源:test_protocol_cybinary.py


示例17: test_write_struct_recur

def test_write_struct_recur():
    b, proto = gen_proto()
    item1 = TItem(id=123, phones=["123456", "abcdef"])
    item2 = TItem(id=456, phones=["123456", "abcdef"])
    pkg = TPkg(id=123, items=[item1, item2])
    proto.write_val(TType.STRUCT, pkg)
    assert ("15 f6 01 19 2c 15 f6 01 19 28 06 31 32 33 34 35 36 06 61 62 63 "
            "64 65 66 00 15 90 07 19 28 06 31 32 33 34 35 36 06 61 62 63 64 "
            "65 66 00 00" == hexlify(b.getvalue()))
开发者ID:AllanDaemon,项目名称:thriftpy,代码行数:9,代码来源:test_protocol_compact.py


示例18: test_write_struct

def test_write_struct():
    b = TMemoryBuffer()
    item = TItem(id=123, phones=['123456', 'abcdef'])
    p = proto.TCyBinaryProtocol(b)
    p.write_struct(item)
    p.write_message_end()
    assert ("08 00 01 00 00 00 7b 0f 00 02 0b 00 00 00 02 00 00 00 "
            "06 31 32 33 34 35 36 00 00 00 06 61 62 63 64 65 66 00") == \
        hexlify(b.getvalue())
开发者ID:noodle4u,项目名称:thriftpy,代码行数:9,代码来源:test_protocol_cybinary.py


示例19: test_write_struct

def test_write_struct():
    trans = TCyMemoryBuffer()
    b = proto.TCyBinaryProtocol(trans)
    item = TItem(id=123, phones=["123456", "abcdef"])
    b.write_struct(item)
    b.write_message_end()
    assert ("08 00 01 00 00 00 7b 0f 00 02 0b 00 00 00 02 00 00 00 "
            "06 31 32 33 34 35 36 00 00 00 06 61 62 63 64 65 66 00") == \
        hexlify(trans.getvalue())
开发者ID:GuoJing,项目名称:thriftpy,代码行数:9,代码来源:test_protocol_cybinary.py


示例20: test_write_wrong_arg_type

def test_write_wrong_arg_type():
    trans = TCyMemoryBuffer()
    b = proto.TCyBinaryProtocol(trans)
    item = TItem(id="wrong type", phones=["123456", "abcdef"])
    try:
        b.write_struct(item)
    except Exception:
        pass
    b.write_message_end()

    item2 = TItem(id=123, phones=["123456", "abcdef"])
    b.write_struct(item2)
    b.write_message_end()
    assert ("08 00 01 00 00 00 7b 0f 00 02 0b 00 00 00 02 00 00 00 "
            "06 31 32 33 34 35 36 00 00 00 06 61 62 63 64 65 66 00") == \
        hexlify(trans.getvalue())
开发者ID:GuoJing,项目名称:thriftpy,代码行数:16,代码来源:test_protocol_cybinary.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python throw.location函数代码示例发布时间:2022-05-27
下一篇:
Python memory.TCyMemoryBuffer类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap