参考:https://www.likecs.com/show-308547984.html
function print_r(t)
local print_r_cache={}
local function sub_print_r(t,indent)
if (type(t)=="table") then
for pos,val in pairs(t) do
if (type(val)=="table") then
print(indent.."["..pos.."] = "..tostring(t).." {")
sub_print_r(val,indent..string.rep(" ",string.len(pos)+8))
print(indent..string.rep(" ",string.len(pos)+6).."}")
elseif (type(val)=="string") then
print(indent.."["..pos..'] = "'..val..'"')
else
print(indent.."["..pos.."] = "..tostring(val))
end
end
else
print(indent..tostring(t))
end
end
if (type(t)=="table") then
print(tostring(t).." {")
sub_print_r(t," ")
print("}")
else
sub_print_r(t," ")
end
print()
end
local record1 = {
["key"] = 1,
["value"] = 2
}
local record2 = {
["key"] = 3,
["value"] = 4
}
local record3 = {record1,record2}
local record = {["where"] = record3}
print_r(record)
版权声明:本文为HHT0506原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。