在python中运行perl脚本并将输出存储在文件中
我想跑在python中运行perl脚本并将输出存储在文件中,python,Python,我想跑 script.pl < input > output script.ploutput 在python中。我试过这个: subprocess.check_call(["script.pl","<","input",">","output"]) subprocess.check_调用([“script.pl”,“output”]) 我想这不是正确的方法。 任何帮助都将不胜感激 要执行shell命令吗 script.pl < input > outp
script.pl < input > output
script.ploutput
在python中。我试过这个:
subprocess.check_call(["script.pl","<","input",">","output"])
subprocess.check_调用([“script.pl”,“output”])
我想这不是正确的方法。
任何帮助都将不胜感激 要执行shell命令吗
script.pl < input > output # 0 args, redirects stdin and stdout
script.pl "<" input ">" output # 4 args, and no redirections
保持简单
import os
os.system("script.pl < input > output")
导入操作系统
操作系统(“script.ploutput”)
os.system(“script.ploutput”)
谢谢!我使用了入跳频和出跳频的方法,效果非常好!
in_fh = open('input', 'r')
out_fh = open('output', 'w')
subprocess.check_call("script.pl", stdin=in_fh, stdout=out_fh)
import os
os.system("script.pl < input > output")