int = 123;
str = "字符串"
--下面的%s对应参数str, %i对应参数int
str = string.format("这是字符串:'%s' 这是数字值 %i",str,int);
win.messageBox(str);
--%05i表示格式化为至少五位的数字,不足在前面补0
str = string.format("%05i",int);
win.messageBox(str);
str = "字符串"
--下面的%s对应参数str, %i对应参数int
str = string.format("这是字符串:'%s' 这是数字值 %i",str,int);
win.messageBox(str);
--%05i表示格式化为至少五位的数字,不足在前面补0
str = string.format("%05i",int);
win.messageBox(str);
本文介绍了一个使用Lua语言进行字符串格式化的简单示例。通过示例展示了如何将变量插入到字符串中,并介绍了两种不同的格式化方式:一种是常规的字符串格式化,另一种则是将整数格式化为固定长度的字符串。

6132

被折叠的 条评论
为什么被折叠?



