20 求一个读取文本然后按照文本顺序登录的示例代码

发布于 2019-08-24 10:29:35

文本格式 如下 122222222222.png

查看更多

关注者
0
被浏览
925
看客
看客 认证专家 2019-08-24

file = io.open("/var/touchelf/scripts/账号.txt","r") --打开一个文件,并返回句柄
team={}
local a=0
for l in file:lines() do

a=a+1
l=    string.gsub(l,"\r","")
l=    string.gsub(l,"\n","")
team[a]=l

end
file:close()
file3 = io.open("/var/touchelf/scripts/计数.txt","r");
if file then

zhn1 = file3:read()
file3:close();
zhn1 = tonumber(zhn1);

else

zhn1 = 1

end
for i = zhn1,#team do

account,password = 分割(team[i])
inputText(account)
inputText(password)
logfile = io.open("/var/touchelf/scripts/计数.txt","w")
logfile:write(i)
logfile:close()

end

3 个回答
看客
看客 认证专家 2019-08-24
file = io.open("/var/touchelf/scripts/账号.txt","r")
team={}
local a=0
for l in file:lines() do
    a=a+1
    l=    string.gsub(l,"\r","")
    l=    string.gsub(l,"\n","")
    team[a]=l
end    
file:close()
file3 = io.open("/var/touchelf/scripts/计数.txt","r");
if file then 
    zhn1 = file3:read()
    file3:close();
    zhn1 = tonumber(zhn1);
else
    zhn1 = 1
end
for i = zhn1,#team do
    account,password = 分割(team[i])
    inputText(account)
    inputText(password)
    logfile = io.open("/var/touchelf/scripts/计数.txt","w")
    logfile:write(i+1)
    logfile:close()
end
Evan
Evan 认证专家 2019-08-25

修正分割部分,假设字符串是 - 连接

acc = Split(team[i],"-")
account,password = acc[1], acc[2]

Split函数见#lua的分割函数Split

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览