function n_serialize(data) if type(data)=="number" then io.write(data," ") elseif type(data)=="string" then io.write(string.format("%q ",data)) elseif type(data)=="table" then io.write("{ "); for k,v in pairs(data) do io.write(" ",k,"=") n_serialize(v) --io.write(", ") end io.write("} ") else end end tbl={a=12,b="lua"} n_serialize(tbl) n_serialize(1) n_serialize("Hello World") local fw=assert(io.open("text.txt",'w')) fw:write("Hello World") fw:close() local fr=assert(io.open("text.txt",'r')) print(fr:read("a")) fr:close()
版权声明:本文为博主原创文章,未经博主允许不得转载。