當前位置: 首頁>>代碼示例>>Python>>正文


Python TMemoryBuffer.write_struct方法代碼示例

本文整理匯總了Python中thriftpy.transport.TMemoryBuffer.write_struct方法的典型用法代碼示例。如果您正苦於以下問題:Python TMemoryBuffer.write_struct方法的具體用法?Python TMemoryBuffer.write_struct怎麽用?Python TMemoryBuffer.write_struct使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在thriftpy.transport.TMemoryBuffer的用法示例。


在下文中一共展示了TMemoryBuffer.write_struct方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_write_huge_struct

# 需要導入模塊: from thriftpy.transport import TMemoryBuffer [as 別名]
# 或者: from thriftpy.transport.TMemoryBuffer import write_struct [as 別名]
def test_write_huge_struct():
    b = TMemoryBuffer()
    b = TCyBufferedTransport(b)
    b = proto.TCyBinaryProtocol(b)
    item = TItem(id=12345, phones=["1234567890"] * 100000)
    b.write_struct(item)
    b.write_message_end()
開發者ID:lepture,項目名稱:thriftpy,代碼行數:9,代碼來源:test_protocol_cybinary.py

示例2: test_write_empty_struct

# 需要導入模塊: from thriftpy.transport import TMemoryBuffer [as 別名]
# 或者: from thriftpy.transport.TMemoryBuffer import write_struct [as 別名]
def test_write_empty_struct():
    b = TMemoryBuffer()
    trans = TCyBufferedTransport(b)
    b = proto.TCyBinaryProtocol(trans)
    item = TItem()
    b.write_struct(item)
    b.write_message_end()
    assert "00" == hexlify(trans.getvalue())
開發者ID:lepture,項目名稱:thriftpy,代碼行數:10,代碼來源:test_protocol_cybinary.py

示例3: test_write_struct

# 需要導入模塊: from thriftpy.transport import TMemoryBuffer [as 別名]
# 或者: from thriftpy.transport.TMemoryBuffer import write_struct [as 別名]
def test_write_struct():
    b = TMemoryBuffer()
    trans = TCyBufferedTransport(b)
    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:lepture,項目名稱:thriftpy,代碼行數:12,代碼來源:test_protocol_cybinary.py


注:本文中的thriftpy.transport.TMemoryBuffer.write_struct方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。