Call python script from ruby

For example, I can use Python scripts in PHP like there:

exec("python script.py params",$result);

where "script.py" - script name and variable $result save output data.

How I can make it with Ruby? I mean, call Python scripts from Ruby.


一种方法是执行。

result = exec("python script.py params")

您可以对任何shell二进制文件执行shell命令并使用反引号捕获响应:

result = `python script.py params`

另一种做同样事情的方法是,

system 'python script.py', params1, params2
链接地址: http://www.djcxy.com/p/25298.html

上一篇: 在ruby中运行linux命令

下一篇: 从ruby调用python脚本