我在 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')
您可以使用连接运算符 '..' :
local data = http.request('http://ip:port/json.htm?type=devices&rid=' .. number)
或字符串格式:
local data = http.request(string.format('http://ip:port/json.htm?type=devices&rid=%d', number))