📅  最后修改于: 2022-03-11 14:45:45.936000             🧑  作者: Mango
import socket
host = "localhost"
ports = [21,22,23,24,25,110,80,443] # Add Port
for port in ports:
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
p = s.connect_ex((host,port))
if p == 0:
print(f"Port: {port} Open!")
else:
print(f"Port: {port} Filter!")