赞
踩
--@param data 要打印的数据
function dump( data )
local str = "\"<var>\" = "
if type(data) ~= "table" then
print(str..tostring(data))
return
else
print(str.."{")
end
for i, v in pairs(data) do
dump_data(i, v, 1)
end
print("}")
end
function dump_data( key, data, depth )
local head = ""
for i = 1, depth do
head = head.."\t"
end
if type(key) == "userdata" then
key = type(key)
end
if type(data) ~= "table" then
print(head..key.." = "..tostring(data))
else
print(head..key.." = {")
depth = depth + 1
for i, v in pairs(data) do
dump_data(i, v, depth)
end
print(head.."}")
end
end
function test( )
local list = { 1, 2, 4, 5, test1 = "dddd", test2 = { 5, 6, 9, 9}}
dump(list)
end
test()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。