复制代码def print_conns_by_proc_pid(pid): system_conns = psutil.net_connections() for conn in system_conns: if conn.pid == pid: print conn