Python implements a simple task manager

This tutorial mainly uses python to implement a simple task manager, which can quickly end the task process.

Table of contents

1. Example code

2. Effect demonstration


1. Example code

#!/usr/bin/python
# -*- coding: UTF-8 -*-
"""
@author: Roc-xb
"""
# encoding:utf-8
import subprocess


def execute_cmd(command):
    subprocess.run('chcp 65001', shell=True)  # 设置CMD编码为UTF-8
    result = subprocess.run(command, shell=True, capture_output=True, text=True)
    print(result.stdout)


if __name__ == '__main__':
    name = input("请输入你要结束的进程名称(支持正则匹配):")
    execute_cmd('taskkill -f -im ' + name + "*")

2. Effect demonstration

It should be noted that to execute the program, you need to run it with administrator privileges.

 

Guess you like

Origin blog.csdn.net/qq_19309473/article/details/135234329