HTTP 请求中的变量值

在 HTTP 请求中,我有一个变量值

local data = http.request('http://ip:port/json.htm?type=devices&rid=3')

数字 3 是一个变量值。 如何在 number 而不是 3 中插入数字?

local data = http.request('http://ip:port/json.htm?type=devices&rid=number')
点赞
用户2858170
用户2858170

你可以使用链接运算符 '..'

local data = http.request('http://ip:port/json.htm?type=devices&rid=' .. number)

或者使用string.format

local data = http.request(string.format('http://ip:port/json.htm?type=devices&rid=%d', number))
2019-03-24 15:14:42