工作笔记::lua 打印 一个table的方法
发布日期:2021-06-30 13:42:12 浏览次数:3 分类:技术文章

本文共 1110 字,大约阅读时间需要 3 分钟。

转载于:

 

function print_r ( t )      local print_r_cache={}    local function sub_print_r(t,indent)        if (print_r_cache[tostring(t)]) then            print(indent.."*"..tostring(t))        else            print_r_cache[tostring(t)]=true            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    end    if (type(t)=="table") then        print(tostring(t).." {")        sub_print_r(t,"  ")        print("}")    else        sub_print_r(t,"  ")    end    print()end

 

转载地址:https://jeason.blog.csdn.net/article/details/108741747 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:工作笔记::VSCode使用笔记--VSCode 设置自定义快捷键 设置自定义运行脚本
下一篇:工作笔记::c++ 运行命令行脚本 启动lua cmd lua 顺序执行多个文件的方法 c++ 开启一个命令行的方法 lua 启动多个文件

发表评论

最新留言

表示我来过!
[***.240.166.169]2024年04月19日 00时24分17秒