fbpx

首页 » Lua » 正文

批量随机写入通讯录源码

function randomStr(num)
local reStr =”;
local s =”abcdefghijklmnopqrstuvwxyz”
math.randomseed(tostring(os.time()):sub(5):reverse());
for i = 1, num do
local getStr = math.random(1, string.len(s));
reStr = reStr .. string.sub(s, getStr, getStr);
end
return reStr;
end

function RandPhone()
math.randomseed(tostring(os.time()):sub(5):reverse())
local firstPhone = {}
firstPhone = {‘134′,’135′,’136′,’137′,’ 138′,’139′,’147′,’150′,’151′,’ 152′,’157′,’158′,’159′,’178′,’182′,’183′,’184′,’187′,’188′}
local phoneNum = firstPhone[math.random(1, #firstPhone)]..math.random(00000000, 999999999)
return phoneNum
end

function addressList(times)
removeAllContactsFromAB();
for var = 1, tonumber(times) do
addContactToAB(randomStr(3),randomStr(4),RandPhone());
end

发表评论

Captcha Code