python新手。我想通过套接字使用熊猫从服务器一次将每一行发送到客户端。我的熊猫显示在客户端cli上,但是在服务器端,我显示的所有输出都是“无”。为服务器编写代码的更好方法是什么?
客户...
import socket
import pandas as pd
import ipdb
HOST = 'SERVER_IP'
PORT = 42050
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
dataframe = pd.read_csv(
"/opt/astral/Walabot-Data/hand-only-target.csv",
header=0,
sep=",",
quotechar="'",
#skiprows=2
usecols=['Target #','x','y','x','amplitude','timestamp'],
)
def get_row():
for row in dataframe.itertuples():
# ipdb.set_trace()
print row
while True:
s.send(str(get_row()))
break
print "Done Sending"
s.close()
服务器...
import socket
import ipdb
result = ""
HOST = 'LOCAL_IP'
PORT = 42050
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
print "Server running", HOST, PORT
s.listen(5)
conn, addr = s.accept()
print'Connected by', addr
while True:
data = conn.recv(409600)
print repr(data)
if not data:
break
print "Done Receiving"
conn.close()