【发布时间】:2016-11-08 01:05:45
【问题描述】:
我有一个带有命令行输入的 Lua 脚本,我想在 Python (2.7) 中运行并读取输出。例如,我将在终端(Ubuntu 14.xx)中运行的代码如下所示:
lua sample.lua -arg1 helloworld -arg2 "helloworld"
如何使用 subprocess 模块在 Python 中运行带有命令行输入的 Lua 脚本?我想应该是这样的:
import subprocess
result = subprocess.check_output(['lua', '-l', 'sample'],
inputs= "-arg1 helloworld -arg2 "helloworld"")
print(result)
这样做的正确方法是什么?
这与下面的链接非常相似,但不同之处在于我也尝试使用命令行输入。下面的问题只是调用(Lua)脚本中定义的 Lua 函数,并将输入直接提供给该函数。任何帮助将不胜感激。
【问题讨论】:
标签: python python-2.7 command-line lua subprocess