print("=================自带库=================")
-- string
-- table
print("=================时间=================")
-- 系统时间
print(os.time())
-- 自定义参数 得到时间
print(os.time({year = 2021, month = 3, day = 3}))
-- 返回一个table
local nowTime = os.date("*t")
for k, v in pairs(nowTime) do
print(k, v)
end
-- hour 11
-- min 43
-- wday 4
-- day 3
-- month 3
-- year 2021
-- sec 14
-- yday 62
-- isdst false
print("=================数学运算=================")
-- 绝对值
math.abs(11)
-- 弧度转角度
math.deg(math.pi())
math.cos(math.pi())
math.floor(2.6)
math.ceil(5.2)
math.max(1, 2)
math.min(4, 5)
math.modf(1.2)
math.pow(2, 5)
-- 随机数
math.randomseed(os.time())
math.random(100)
math.sqrt( 4 )
print("=================路径=================")
print(package.path)
print("=================垃圾回收=================")
test = {id= 1, name = "123123"}
-- 垃圾回收关键字
-- collectgrabage
-- 获取当前lua占用内存数,K字节 用返回值 * 1024就可以得到具体的内存占用字节数
print(collectgarbage("count"))
-- 20.15234375
test = nil
--进行垃圾回收 理解有点像C# 的GC
collectgarbage("collect")
print(collectgarbage("count"))
20.51953125
19.3466796875
Lua常用库,垃圾回收
最新推荐文章于 2024-06-27 06:37:22 发布