1. 首页
  2. 数据库
  3. 其它
  4. python判断端口是否打开的实现代码

python判断端口是否打开的实现代码

上传者: 2020-12-31 15:58:49上传 PDF文件 23.39KB 热度 19次
复制代码 代码如下:#!/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
下载地址
用户评论