标签:功能 get def imp import nec close try finally
利用Python原始库完成一个端口扫描的功能
import socket
def get_ip_status(ip,port):
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
server.connect((ip,port))
print('{0} port {1} is open'.format(ip, port))
except Exception as err:
print('{0} port {1} is not open'.format(ip,port))
finally:
server.close()
get_ip_status("192.168.221.133",22)
标签:功能 get def imp import nec close try finally
原文地址:https://www.cnblogs.com/17bdw/p/11551752.html