function print_r( t )
local print_r_cache={}
local space = " "
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 .. " = " .. "{")
sub_print_r(val, indent .. space)
print(indent .. "},")
else
print(indent .. pos .. " = " .. tostring(val) .. ',')
end
end
else
print(indent .. tostring(t))
end
end
if (type(t)=="table") then
print("{")
sub_print_r(t, space)
print("}")
else
sub_print_r(t, space)
end
end
示例:
local a = {3, 4, 5}
print_r(a)
版权声明:本文为qq_30372933原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。