温馨提示×

Lua中怎么拼接字符串

Lua
小亿
260
2024-04-09 09:18:41
栏目: 编程语言
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

在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.

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读:lua字符串拼接的方法是什么

0