-3
我不知道红宝石,但我知道蟒蛇。什么是运行下面的代码的python等价物?这个例子来自redis网站。那么,这是什么?Redis lua脚本 - 用Ruby编写的lua脚本的python等价物是什么?
<<EOF?
会是在Python:
RandomPushScript = """
Lua code here
"""
RandomPushScript = <<EOF
local i = tonumber(ARGV[1])
local res
math.randomseed(tonumber(ARGV[2]))
while (i > 0) do
res = redis.call('lpush',KEYS[1],math.random())
i = i-1
end
return res
EOF
r.del(:mylist)
puts r.eval(RandomPushScript,1,:mylist,10,rand(2**32))
[Stack Overflow不是代码翻译服务](http://meta.stackexchange.com/a/129362/164572) –
对不起,“用Ruby编写的Lua脚本”? Lua和Ruby是不同的语言,Python还不到三分之一。 –
@DanielRoseman如上所示,这是一个Ruby脚本,它似乎创建了一个Lua脚本作为一个大字符串,然后对它做了一些处理。 – Phrogz