function n_serialize(data) if type(data)=="number" then io.write(data,"\n") elseif type(data)=="string" then io.write(string.format("%q\n",data)) elseif type(data)=="table" then io.write("{\n"); for k,v in pairs(data) do io.write(" ",k,"=") n_serialize(v) --io.write(",\n") end io.write("}\n") 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()
版权声明:本文为博主原创文章,未经博主允许不得转载。