我正在尝试使用 Thrift 似乎支持的 python 3.4的Apache Thriftlib.linux-x86_64-3.4
,因为它
在build
目录下。但我不断收到此错误消息
File "/home/qunzi/Downloads/thrift-0.9.2/lib/py/build/lib.linux-x86_64-3.4/thrift/transport/TTransport.py", line 163, in write
self.__wbuf.write(buf)
TypeError: string argument expected, got 'bytes'
任何人都知道发生了什么,并且可能有解决方案?
下面是相关代码
socket = TSocket.TSocket('localhost', 9090)
transport = TTransport.TBufferedTransport(socket)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
client = Algo.Client(protocol)
transport.open()
ping_req = PingRequest()
ping_resp = client.ping(ping_req)
整个追溯:
File "py3client.py", line 36, in <module>
ping_resp = client.ping(ping_req)
File "/home/qunzi/Projects/test/sample_Test/py3.4_thrift/ib/Algo.py", line 66, in ping
self.send_ping(request)
File "/home/qunzi/Projects/test/sample_Test/py3.4_thrift/ib/Algo.py", line 70, in send_ping
self._oprot.writeMessageBegin('ping', TMessageType.CALL, self._seqid)
File "/home/qunzi/Downloads/thrift-0.9.2/lib/py/build/lib.linux-x86_64-3.4/thrift/protocol/TBinaryProtocol.py", line 46, in writeMessageBegin
self.writeI32(TBinaryProtocol.VERSION_1 | type)
File "/home/qunzi/Downloads/thrift-0.9.2/lib/py/build/lib.linux-x86_64-3.4/thrift/protocol/TBinaryProtocol.py", line 111, in writeI32
self.trans.write(buff)
File "/home/qunzi/Downloads/thrift-0.9.2/lib/py/build/lib.linux-x86_64-3.4/thrift/transport/TTransport.py", line 163, in write
self.__wbuf.write(buf)
TypeError: string argument expected, got 'bytes'