如何通过套接字发送命令以列出目录中的文件?
#
# Write a script that connects to 'localhost' port 10000
# You then need to send a command to list the files in the /tmp directory
#
import socket, os, json
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("localhost", 10000))
cmd = json.dumps(os.listdir("/tmp"))
sock.send(cmd.encode())
print(sock.recv(1024).decode())
它完全没有给我任何输出。是什么赋予了?
慕标5832272
相关分类