首页 > 代码库 > python3.4端口检测:

python3.4端口检测:

python3.4端口检测:

import sys,time,socket
#a=‘sys.argv[0]‘
#b=‘sys.argv[1]‘
#c=‘sys.argv[2]‘
while 1:
    time.sleep(1)
    try:
        sc=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
        ip = sys.argv[1]
        port = int(sys.argv[2])
        sc.settimeout(3)
        sc.connect((ip,port))
        print (ip,‘:‘,port,‘成功!‘)
    except:
        print(ip,‘:‘,port,‘失败!‘)
#print (a,b,c)
#os.system(‘pause‘)

python3.4端口检测: