local chars = for i = 65 90 do local char = stringchari printcharend输出结果是ABCDEFGHIJKLMNOPQRSTUVWXYZ怎么在C下面添加HS74变成输出结果ABCDEFGHIJKLMNOPQRSTUVWXYZ我说的在C下面添加HS74不是最后面添加HS74
你可以在循环中添加一个判断条件,当循环到字符'C'时,就将字符'HS74'添加进去。如下所示:
local chars = {} for i = 65, 90 do local char = string.char(i) if char == 'C' then table.insert(chars, 'HS74') end table.insert(chars, char) end
for _, char in ipairs(chars) do print(char) end
输出结果为: A B C HS74 D E F G H I J K L M N O P Q R S T U V W X Y Z
原文地址: https://www.cveoy.top/t/topic/btEd 著作权归作者所有。请勿转载和采集!