摘要: addNum = function(a, b) assert(type(a) == 'string','a必须是一个字符串') assert(type(b) == 'string','b必须是一个字符串') return a..' '..b end print(addNum('hello','wor 阅读全文
posted @ 2022-09-21 17:53 90的生力军 阅读(31) 评论(0) 推荐(0) 编辑
摘要: -- 以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。(EOF符保留) file = io.open("D:\\Program Files (x86)\\Lua\\5.1\\lua\\testlua.lua", "a+") - 阅读全文
posted @ 2022-09-21 17:51 90的生力军 阅读(116) 评论(0) 推荐(0) 编辑
摘要: local jsonutil = require("json.util") local merge = require("json.util").merge local tostring = tostring local tab1={} table.insert(tab1,1,"aaa") tabl 阅读全文
posted @ 2022-09-21 17:48 90的生力军 阅读(73) 评论(0) 推荐(0) 编辑
摘要: array = {"Google", "Runoob"} table.insert(array,1,"hello world!") for k, v in ipairs(array) do print('k->'..k .. ',v->' .. v) end table.sort(array) fo 阅读全文
posted @ 2022-09-21 17:45 90的生力军 阅读(62) 评论(0) 推荐(0) 编辑
摘要: local testlua = require "testlua" --testlua.compertoNum(1, 2, 4, 5, 11, 23, 543, 123, 45, 2131, 12) testlua.testMethod('123545') 阅读全文
posted @ 2022-09-21 17:43 90的生力军 阅读(212) 评论(0) 推荐(0) 编辑
摘要: --function maxnum(tab1) -- local b = 1 -- local a = tab1[b] -- for i, v in ipairs(tab1) do -- if v > a then -- a = v -- end -- end -- return a --end - 阅读全文
posted @ 2022-09-21 17:40 90的生力军 阅读(88) 评论(0) 推荐(0) 编辑