语言:python3    系统:ubuntu18   只能在Unix系统运行

import os
import re
import signal


# 要杀死程序名称,最好全名
program_name = "chromedriver"
# 终端执行的命令
order_str = "ps x | grep %s" % program_name
# 执行
strs_obj = os.popen(order_str)
t_strs = strs_obj.read()
# 通过正则获取pid
pid_list = re.findall(r"(\d+).+chromedriver --port=\d+", t_strs, re.I)
print(pid_list)
for j in pid_list:
    print(j)
    # 杀死进程
    os.kill(int(j), signal.SIGKILL)