Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 Lua 语言,并且我有一长串二进制数,我想将其放入一个数组中,每个数字都作为数组中自己的元素。
local str, out = "01101101010010010", {} for i = 1, #str do out[#out+1] = string.sub(str,i,i) end
out[#out+1] = tonumber(string.sub(str,i,i))如果您希望数组包含数字而不是字符串,请将第 3 行更改为。
out[#out+1] = tonumber(string.sub(str,i,i))