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分词程序的,传递纯文本文件的路径,然后将结果返回。
相关推荐
以梦为马不负韶华 2020-10-20
tianhuak 2020-11-24
huha 2020-10-16
lianshaohua 2020-09-23
laisean 2020-11-11
zhangjie 2020-11-11
大牛牛 2020-10-30
firefaith 2020-10-30
liguojia 2020-10-20
wangzhaotongalex 2020-10-20
CARBON 2020-10-20
彼岸随笔 2020-10-20
lianshaohua 2020-10-20
yutou0 2020-10-17
JohnYork 2020-10-16
xiaonamylove 2020-10-16
Julyth 2020-10-16
applecarelte 2020-10-16
ourtimes 2020-10-16