我有一个带有命令行输入的Lua脚本,我想用Python(2.7)运行并读取输出。例如,我会在终端(Ubuntu的14.xx)运行代码的样子:在Python中使用子进程模块运行带命令行输入的lua脚本
lua sample.lua -arg1 helloworld -arg2 "helloworld"
如何运行使用的子模块在Python命令行中输入一个Lua脚本?我认为它会是这样的:
import subprocess
result = subprocess.check_output(['lua', '-l', 'sample'],
inputs= "-arg1 helloworld -arg2 "helloworld"")
print(result)
什么是正确的方法来做到这一点?
这与以下链接非常相似,但不同之处在于我尝试使用命令行输入。下面的问题只是调用(Lua)脚本中定义的Lua函数,并将输入直接提供给该函数。任何帮助将非常感激。
这对我来说工作,看起来像最完整的答案。谢谢! – sfortney