在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
require("json") result = { ["ip"]="192.168.0.177", ["date"]="2018-1-21", } local test = assert(io.open("/tmp/abc.txt", "w")) result = json.encode(result) test:write(result) test:close() require("json") local test = io.open("/tmp/abc.txt", "r") local readjson= test:read("*a") local table =json.decode(readjson) test:close() print("ip: " .. table["ip"]) 参考: https://my.oschina.net/u/223340/blog/382895 http://lua-users.org/wiki/SaveTableToFile https://stackoverflow.com/questions/36834786/how-to-save-a-table-to-a-file-from-lua/48517263#48517263 |
请发表评论