我不知道红宝石,但我知道蟒蛇。运行以下代码的 python 等效项是什么?这个例子取自 redis 网站。那么,这是什么?
<<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))