python调用powershell

*用于调用查找神器everything的IPC接口:python

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

import os
import time
import traceback
import subprocess

def run_cmd(cmd):
    print 'CMD:%s' %cmd
    args=cmd
    p=subprocess.Popen(args, stdout=subprocess.PIPE)
    dt=p.stdout.read()
    return dt


search_name = 'jiangkun'
cmd = "C:\Users\jiang-kun\Downloads\es\es"
real_cmd = cmd+' -i '+ search_name
line_list = run_cmd(real_cmd).split('\n')
print len(line_list)
lenth = len(line_list)
for i in range(lenth):
    print "%s : %s" %(i, line_list[i])
print line_list[1]

everything程序进程必须存在才能使用,不过也已经很不错了,若是有须要能够本身扩展功能。固然,仍是要使用everything快速的索引。code

相关文章
相关标签/搜索