复制代码 代码如下:#!/usr/bin/env python# name IsOpen.pyimport osimport socketdef IsOpen(ip,port): s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) try: s.connect((ip,int(port))) s.shutdown(2) print ‘%d is open’ % port return True except: print ‘%d is down’ % p