小编A H*_*ler的帖子

在LUA中将数组转换为字符串

尝试将其转换为字符串,这 customLog2 = {}看起来真的像 Log = { {Group = ID, Pos = Numbers}, {Group = ID, Pos = Numbers} } 我尝试过的

local Data = string.format( "LogBook = %s ", customLog2 )
Run Code Online (Sandbox Code Playgroud)

但是因为 CustomLog 是一个数组而不是字符串或数字,所以我无法插入它。我正在尝试将数组转换为字符串,VariableFile:write(Data)所以如果有人可以提供帮助,那就太好了,谢谢。

所以我希望我的输出看起来像这样"local Data = string.format( "LogBook = %s ", customLog2 )",这样我就可以使用 :write 然后在我新创建的文件中它应该看起来像这样Log = { {Group = ID, Pos = Numbers}, {Group = ID, Pos = Numbers} }

所以这个函数可以正常工作,但需要做一件事。

function TableSerialization(t, i)
    local text = "{\n"
    local tab = ""
    for …
Run Code Online (Sandbox Code Playgroud)

arrays string lua

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

arrays ×1

lua ×1

string ×1