我看到了很多将字符串转换为整数的答案,但是如何将整数转换为字符串呢?当我尝试使用microseconds.toString()
时,会出现以下错误:attempt to index upvalue 'microseconds' (a number value)
请注意,这是在运行os 4.5.0.1180的ti-nspire上进行的。
感谢您能提供的任何帮助!
来自https://www.lua.org/manual/5.1/manual.html#pdf-tostring
tostring (e)
接收任何类型的参数并将其转换为合理格式的字符串。要完全控制数字的转换方式,请使用
string.format
。如果 e 的元表具有 "__tostring
" 字段,则 tostring 调用相应值并使用调用结果作为其结果。
tostring
在NSpire Lua脚本API参考指南的第1章第1页中提到...
string.format("%d", microseconds)
,但在字符串拼接"foo" .. microseconds
中,数字应该被强制转换为字符串。 - Henri Menke