标签:string ble pairs turn function class end ring table
function tableToString(studentNum) local str = "{ " str = str.."\n" for k, v in pairs(studentNum) do if type(v) ~= "table" then str = str.."[\""..k.."\"]" str = str..":" str = str..v str = str.."," str = str.."\n" else str = str.."[\""..k.."\"]" str = str..":" str = str..tableToString(v) str = str.."," str = str.."\n" end end str = string.sub(str, 1, -3) str = str.."\n" str = str .." }" return str -- print("tableToString===", str) end local studentNum = {1, {6, 7, {"hello", "world"}}, 5} local str = tableToString(studentNum) print(str)
标签:string ble pairs turn function class end ring table
原文地址:http://www.cnblogs.com/xshang/p/7783290.html