Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器

首页 / 操作系统 / Linux / Python 重定向shell执行输出

本文有两个主题:1.python执行shellos.system("command line")2.重定向之后shell后的输出def getkeyword(puretext):
    try:
     app = ["java","-cp","IKAnalyzer2012_u6.jar:.","htParticiple","-f","acm.nyist.net"] #call the java programe
     proc = subprocess.Popen(app,stdout=subprocess.PIPE)                                #redirect the python out
     return proc.stdout.read()
    except:
     return "ERROR"这个代码是执行java分词程序的,传递纯文本文件的路径,然后将结果返回。