gpt4 book ai didi

random - 表值返回零?

转载 作者:行者123 更新时间:2023-12-04 02:54:04 25 4
gpt4 key购买 nike

我正在制作一个随机词生成器,但遇到了一个小问题。我正在尝试从包含 closedLetters(c、d、f 等)的表中打印值,但它不起作用。它返回零。帮忙?

local closedLetters={b, c, d, f, g, h, j, k, l, m, n, p, q, r, s, t, v, w, x, z}
local openLetters={a, e, i, o, u, y}
print(closedLetters[2])

(那段代码只是一个例子,我设置的其实更像这样)

local closedLetters={b, c, d, f, g, h, j, k, l, m, n, p, q, r, s, t, v, w, x, z}
local openLetters={a, e, i, o, u, y}
print(closedLetters[math.random(#closedLetters)]..openLetters[math.random(#openLetters)])

最佳答案

你在那个表中只有一堆键。具有 nil 值的键,因此您的返回值。将它们改为文字:closedLetters= {'a', 'b', .....}

关于random - 表值返回零?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17516614/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com