# lua_mockdata **Repository Path**: mappoer/lua_mockdata ## Basic Information - **Project Name**: lua_mockdata - **Description**: lua假数据模拟测试 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: dev - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-03-02 - **Last Updated**: 2025-10-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## mockdata.lua 假数据生成 * @date(format,time) * @random(min,max) * @idx() * @range(start,end,step) * function * regex * 变量标记 `|r` * 数字 `%d` * 小写字母`%w` * 大写字母`%W` * 重复n次`{n}` * ascii码范围字符组合 * 仅数字`[0-9]`或者`[%d]`,仅有1或9`[19]`,不包含1和9`[02-8]` * 所有数字和字母`[0-9%w%W]` * 字符范围在`!#$%^()*+,.-.` (包含\`符号) 中随机 `[!#-.]` ```lua mockdata({ --- ["name|r"] = "[张王李吴][甲乙丙丁][一二三四五六七八九]", ["uid|7"] = "@random(0,9)", ["age"] = "@random(1,200)", ["ageDesc"] = function(o) return "年龄:" .. o.age .. "岁" end, ["star|1-10"] = "★", ["timestamp"] = "@date", ["nowTime"] = "@now", ["rangeArr"] = "@range(3,7,2)", ["timeFormat"] = "开始:@date(%Y-%m-%d %H:%M:%S) 结束:@date(%Y-%m-%d %H:%M:%S),指定:@date(%Y-%m-%d %H:%M:%S, 992165489)", ["itemArr|1-3"] = { { ["id|+1"] = 0, ["name|r"] = "最[低中高]级", ["price"] = "@random(10,100)", } }, ["UUID|r"] = "(%d{5,10}-){2}%d{5,10}", }) ``` ```lua { ["name"] = "张丁一", ["uid"] = "1290190", ["age"] = 31, ["ageDesc"] = "年龄:31岁", ["star"] = "★★★★", ["timestamp"] = 1726734217, ["nowTime"] = "10/29/24 17:30:12", ["rangeArr"] = { [5] = 5, [7] = 7, [3] = 3, }, ["timeFormat"] = "开始:2024-06-26 13:22:08 结束:2024-06-26 13:22:08,指定:2001-06-10 17:31:29", ["itemArr"] = { [1] = { ["id"] = 1, ["name"] = "最低级", ["price"] = 46, }, [2] = { ["id"] = 2, ["name"] = "最中级", ["price"] = 51, }, }, ["UUID"] = "3123012012-3014123123-412312", } ```