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')

相关文章

python多进程实现文件下载传输功能

本文实例为大家分享了python多进程实现文件下载传输功能的具体代码,供大家参考,具体内容如下 需求: 实现文件夹拷贝功能(包括文件内的文件),并打印拷贝进度 模块: os模块 mu...

python+mysql实现简单的web程序

这次要为我的python程序加上数据库,主要是实现从mysql中查询出数据并在页面上显示出来。 首先是mysql的配置文件config.py host="127.0.0.1" use...

python实现调用其他python脚本的方法

本文实例讲述了python实现调用其他python脚本的方法,分享给大家供大家参考。具体方法如下: 该实例调用当前目录下的md5get.py脚本。代码如下: import os i...

使用Python处理Excel表格的简单方法

使用Python处理Excel表格的简单方法

Excel 中的每一个单元,都会有这些属性:颜色(colors)、number formatting、字体(fonts)、边界(borders)、alignment、模式(pattern...

解决pytorch GPU 计算过程中出现内存耗尽的问题

Pytorch GPU运算过程中会出现:“cuda runtime error(2): out of memory”这样的错误。通常,这种错误是由于在循环中使用全局变量当做累加器,且累加...