集合输出
#/usr/bin/env python3
#linstening port
ports = []
import subprocess
s1 = ('80', '8090', '8000', '22', '25')
ret = subprocess.getoutput('ss -ntal')
for line in ret.split('\n'):
if line.startswith('LISTEN'):
host_port = line.split()[3]
port = host_port.split(':')[-1]
if port in ports:
continue
ports.append(port)
s1 = set(s1)
s2 = set(ports)
print( s1 & s2)