Lua " />

扫描二维码下载沐宇APP

沐宇

微信扫码使用沐宇小程序

沐宇

Lua中怎么拼接字符串

扬州沐宇科技
2024-04-09 09:18:41
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.

扫码添加客服微信