import tn=telnetlib.Telnet(host,port)不报异常则该端口是通的,可结合try进行使用 转载于:https://www.cnblogs.com/poerli/p/6030961.html