Linux 拨号vps windows公众号手机端

Lua中怎么拼接字符串

lewis 7年前 (2018-04-04) 阅读数 10 #程序编程
文章标签 Lua

在Lua中,可以使用..操作符来拼接字符串。例如:

local str1 = "Hello"
local str2 = "World"
local result = str1 .. " " .. str2
print(result) -- Output: Hello World

另外,也可以使用string.format函数来格式化字符串,然后再拼接。例如:

local name = "Alice"
local age = 30
local result = string.format("My name is %s and I am %d years old.", name, age)
print(result) -- Output: My name is Alice and I am 30 years old.
版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门