我有一个列表列表,希望将其从python服务器发送到c#客户端。
这是代码:
s = socket.socket()
socket.setdefaulttimeout(None)
print('socket created ')
port = 60000
s.bind(('127.0.0.1', port)) #local host
s.listen(30) #listening for connection for 30 sec?
print('socket listensing ... ')
while True:
try:
c, addr = s.accept() #when port connected
bytes_received = c.recv(4000) #received bytes
array_received = np.frombuffer(bytes_received, dtype=np.float32)
print(array_received)
nn_output = return_prediction()
c.sendall(nn_output) #sending back
c.close()
except Exception as e:
logging.error(traceback.format_exc())
print("error")
c.sendall(bytearray([]))
c.close()
break
错误:TypeError:需要一个类似字节的对象,而不是“列表”
是否有可能使其正常工作?