标签:env TE /usr int end server add rip encoding
server-----------------
#!/usr/bin/env python
# encoding: utf-8
# Date: 2018/6/5
import socket
phone = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
phone.bind((‘127.0.0.1‘, 8081))
phone.listen(5)
print(‘starting.......‘)
conn, client_addr = phone.accept()
print(client_addr)
while True:
data = conn.recv(1024)
print(‘客户端的数据‘, data)
conn.send(data.upper())
conn.close()
phone.close()
client--------------------
#!/usr/bin/env python
# encoding: utf-8
# Date: 2018/6/5
import socket
phone = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
phone.connect((‘127.0.0.1‘, 8081))
while True:
msg = input(‘>>>‘).strip()
phone.send(msg.encode(‘utf-8‘))
data = phone.recv(1024)
print(data.decode(‘utf-8‘))
phone.close()
标签:env TE /usr int end server add rip encoding
原文地址:https://www.cnblogs.com/fmgao-technology/p/9189386.html