telnetlib入门
import telnetlib tn = telnetlib.Telnet("127.0.0.1","7171") #服务器,端口 result = tn.read_very_eager().decode('ascii') print(result) cmd = "status,1\r\n" tn.write(cmd.encode()) print(cmd) result = tn.read_very_eager().decode('ascii') print(result) tn.close()