python 判断一个进程是否存在

yipeiwu_com6年前Python基础
源代码如下:
复制代码 代码如下:

#-*- coding:utf-8 -*-
def check_exsit(process_name):
import win32com.client
WMI = win32com.client.GetObject('winmgmts:')
processCodeCov = WMI.ExecQuery('select * from Win32_Process where Name="%s"' % process_name)
if len(processCodeCov) > 0:
print '%s is exists' % process_name
else:
print '%s is not exists' % process_name

if __name__ == '__main__':
check_exsit('chrome.exe')

相关文章

Django框架中render_to_response()函数的使用方法

通常的情况是,我们一般会载入一个模板文件,然后用 Context渲染它,最后返回这个处理好的HttpResponse对象给用户。 我们已经优化了方案,使用 get_template()...

详解Django项目中模板标签及模板的继承与引用(网站中快速布置广告)

详解Django项目中模板标签及模板的继承与引用(网站中快速布置广告)

Django项目中模板标签及模板的继承与引用 常见模板标签 {% static %} {% for x in range(x) %}{% endfor %} 循环的序号{% forl...

使用Pyinstaller转换.py文件为.exe可执行程序过程详解

使用Pyinstaller转换.py文件为.exe可执行程序过程详解

 前言 pyinstaller能够在Windows、Linux等操作系统下将Python脚本打包成可直接运行程序。使Python脚本可以在没有安装Python的环境中直接运行,...

tensorflow没有output结点,存储成pb文件的例子

tensorflow没有output结点,存储成pb文件的例子

Tensorflow中保存成pb file 需要 使用函数 graph_util.convert_variables_to_constants(sess, sess.graph_def,...

python3.6使用tkinter实现弹跳小球游戏

本文实例为大家分享了python3.6实现弹跳小球游戏的具体代码,供大家参考,具体内容如下 import random import time from tkinter import...