lua io.write()写入顺序问题
tolog=function(str)localfile=io.open("log.txt","a")str="["..os.date().."]:"..str.."\n...
tolog = function(str)
local file = io.open("log.txt","a")
str = "["..os.date().."]: "..str.."\n"
file:write(str)
end
for i = 1 ,100000000 ,1 do
if math.mod(i,1000) == 0 then
tolog(i+x)
end
end
代码,以上,输出的log.txt
[11/25/13 11:58:10]: 8000
[11/25/13 11:58:10]: 7000
[11/25/13 11:58:10]: 6000
[11/25/13 11:58:10]: 5000
[11/25/13 11:58:10]: 4000
[11/25/13 11:58:10]: 3000
[11/25/13 11:58:10]: 2000
[11/25/13 11:58:10]: 1000
[11/25/13 11:58:10]: 11000
[11/25/13 11:58:10]: 10000
[11/25/13 11:58:10]: 9000 展开
local file = io.open("log.txt","a")
str = "["..os.date().."]: "..str.."\n"
file:write(str)
end
for i = 1 ,100000000 ,1 do
if math.mod(i,1000) == 0 then
tolog(i+x)
end
end
代码,以上,输出的log.txt
[11/25/13 11:58:10]: 8000
[11/25/13 11:58:10]: 7000
[11/25/13 11:58:10]: 6000
[11/25/13 11:58:10]: 5000
[11/25/13 11:58:10]: 4000
[11/25/13 11:58:10]: 3000
[11/25/13 11:58:10]: 2000
[11/25/13 11:58:10]: 1000
[11/25/13 11:58:10]: 11000
[11/25/13 11:58:10]: 10000
[11/25/13 11:58:10]: 9000 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询