use*_*258 8 string lua lua-table
我想将字符串文本转换为表格,此文本必须分为字符.每个字符必须在表的单独值中,例如:
mot*_*eus 10
你可以使用string.gsub函数
t={}
str="text"
str:gsub(".",function(c) table.insert(t,c) end)
Run Code Online (Sandbox Code Playgroud)
只需索引每个符号并将其放在表中的相同位置.
local str = "text"
local t = {}
for i = 1, #str do
t[i] = str:sub(i, i)
end
Run Code Online (Sandbox Code Playgroud)