加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

lua – 将变量连接成文字字符串

发布时间:2020-12-15 00:25:11 所属栏目:大数据 来源:网络整理
导读:我试图将变量连接成一个纯文字字符串,纯粹是出于可读性目的,例如 myString = "test"myString2 = [[first part of the stringthis is a " .. myString .. " stringlast part of the string]]print(myString2) 但这确实是输出 first part of the stringthis is
我试图将变量连接成一个纯文字字符串,纯粹是出于可读性目的,例如
myString = "test"
myString2 = [[
first part of the string
this is a " .. myString .. " string
last part of the string]]
print(myString2)

但这确实是输出

first part of the string
this is a " .. myString .. " string
last part of the string

我确信它很简单,但我已经尝试使用谷歌搜索来了解如何实现这一目标并且空白.

解决方法

双括号分隔符内的引号没有做任何事情.结束双支架的唯一方法是使用双支架:
myString2 = [[
first part of the string
this is a ]] .. myString .. [[ string
last part of the string]]

那会给你:

first part of the string
this is a test string
last part of the string

见:http://www.lua.org/pil/2.4.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读