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

相關文章
相關標籤/搜索