lua二维数组问题求助:怎么用lua逐行输出txt文档
lua吧
全部回复
仅看楼主
level 3
y风吹过b 楼主
怎么用lua逐行输出txt文档
比如:
txt文档内容:
66.123421,77,657432
66.123421,77,657432
66.123421,77,657432
66.123421,77,657432
66.123421,77,657432
如何调用里面的内容,并输出
输出格式如下
print(arry[1][1]=66.123421,77,arry[1][2]=77,657432)
.
.
.
依次向下读取,最好可以循环
(想弄个循环伪装定位)
谢谢吧内大神指点,最好是实操代码 感激不尽!
2015年08月23日 12点08分 1
level 11
io.write
io.read
完成你的需求
2015年08月24日 00点08分 2
level 11
文档格式玩弄好 不然不好处理
2015年08月24日 00点08分 3
level 11
其实你可以用lua来储存数据
2015年08月24日 00点08分 4
level 3
y风吹过b 楼主
我想用2维数组,指针循环输出,就是程序循环一遍,换一行。求大神代码实例。
2015年08月24日 03点08分 5
...你这格式...哎...
2015年08月25日 09点08分
level 11
...你这格式。。。叫我如何是好。。。
io.input("")
local arry={}
local temp,o=0,""
local i=1
while io.seek()~="end" do
temp=io.line()
arry[i]={}
o[1],o[2],o[3]=string.match(temp,"(%S+),(%S+)(,%S+)")
table.insert(arry[i],o[1]..","..o[2])
table.insert(arry[i],o[2]..o[3])
i=i+1
end
2015年08月25日 09点08分 6
o定义错了,o={}
2015年08月25日 09点08分
66.123421,77.657432 66.123421,77.657432 66.123421,77.657432 66.123421,77.657432 66.123421,77.657432 66.123421,77.657432 格式搞错了!
2015年08月26日 07点08分
level 3
y风吹过b 楼主
66.123421,77.657432
66.123421,77.657432
66.123421,77.657432
66.123421,77.657432
66.123421,77.657432
66.123421,77.657432
2015年08月26日 07点08分 7
level 11
o[1],o[2]=string.match(temp,(“%S+.%S+),((“%S+.%S+))”)
table.insert(arry[i],o[1])
table.insert(arry[i],o[2])
如果你的格式是66.123421,77.657432 ,arry[1] arry[2]中分别是66.123421 和 77.657432
2015年08月26日 09点08分 8
1