python杀掉windows端口号对应进程

#! /usr/bin/python

# -*- coding: utf-8 -*-

import os

taskinfo = os.popen('netstat -ano | findstr 8084')

line = taskinfo.readline()

aList = line.split()

taskinfo.close()

pid = aList[4]

os.popen('taskkill /pid %s /f' % pid)

你可能感兴趣的:(python杀掉windows端口号对应进程)