[英]Passing an argument from ruby to a python scripts
I have a problem that I hope you guys can help me out with. 我有一个问题,我希望你们可以帮助我。 Im making a home automation system with RPi + Piface to control devices on the network.
我使用RPi + Piface制作家庭自动化系统来控制网络上的设备。
#----------------------------------------------------------------------------------------
# LIGHTS Automation
#----------------------------------------------------------------------------------------
room=0
listen_for /Turn on kitchen lights/i do
lights('kitchen')
request_completed
end
def lights(varible)
IO.popen("python /root/SiriProxy/plugins/siriproxy-teamsiri/TeamsiriPython/test.py varible")
end
this is my line of code. 这是我的代码行。 Im calling a python script and it works fine but I want use functions "varible"will be the varible to pass to the script but it does not send it as a varible but a string.
我调用一个python脚本,它工作正常,但我想使用函数“varible”将是传递给脚本的变量,但它不会发送它作为一个变量而是一个字符串。 Any one got some good ideas how to solve it
任何人都有一些好主意如何解决它
Change 更改
IO.popen("python /root/SiriProxy/plugins/siriproxy-teamsiri/TeamsiriPython/test.py varible")
to 至
IO.popen("python /root/SiriProxy/plugins/siriproxy-teamsiri/TeamsiriPython/test.py #{variable}")
and the variable value will be substituted into the string. 并且变量值将被替换为字符串。
Note that this only works inside double-quoted strings. 请注意,这仅适用于双引号字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.