-- å¦æå¾
å¤æçæ¯ä¸ä¸ªåé
local t = type(x);
if t == "number" then
-- æ¯æ°å
else if t == "string" then
-- æ¯å符串
end
-- å¦æ带å¤ææ¯ä¸ä¸ªå符串,è¦å¤ææ¯å¦å¯ä»¥è½¬ææ°å, å
local n = tonumber(x);
if n then
-- nå°±æ¯å¾å°æ°å
else
-- 转æ°å失败,ä¸æ¯æ°å, è¿æ¶n == nil
end
温馨提示:答案为网友推荐,仅供参考