设为首页 加入收藏

TOP

Python 重定向shell执行输出
2014-11-24 03:17:14 来源: 作者: 【 】 浏览:1
Tags:Python 定向 shell 执行 输出

本文有两个主题:


1.python执行shell


os.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分词程序的,传递纯文本文件的路径,然后将结果返回。



】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇ARM ELF 文件格式常见段名称及自.. 下一篇Python 用socket模块实现检测端口..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·哈希表 - 菜鸟教程 (2025-12-24 20:18:55)
·MySQL存储引擎InnoDB (2025-12-24 20:18:53)
·索引堆及其优化 - 菜 (2025-12-24 20:18:50)
·Shell 中各种括号的 (2025-12-24 19:50:39)
·Shell 变量 - 菜鸟教 (2025-12-24 19:50:37)