打印lua内部结构的函数调用

阅读 48

2022-08-02

function printTableInner(t,depth)

for k,v in pairs(t) do

if type(v) == "table" then

print(string.rep(" ", depth)..'table,',k)

printTableInner(v,depth+1)

else

print(string.rep(" ", depth)..k..","..v )

end



end

end



function printTable(t)
for k,v in pairs(t) do
if type(v) == "table" then
print('table,',k)
printTableInner(v,1)
elseif type(v) == "function" then
print('function,',k)
else
print(k..",",v )
end
end
end

精彩评论(0)

0 0 举报