Lua中将字符串中的所有字符变成小写

发布于 2024-09-08 23:38:55 字数 179 浏览 3 评论 0原文

事情是这样的。我试图在 Lua 中将字符串转换为小写,但它不起作用。我已经这样做了,

String = String:lower()

但它不喜欢它。我确信这就是这样做的方法,我以前见过这样做的。一些网站表明这可能是由错误版本的解释器引起的问题。

有什么想法吗?

Here is the thing. I am trying to convert a string in lowercase in Lua, but it's not working. I have done this

String = String:lower()

but it doesn't like it. I am sure that is the way to do it, I've seen it done before. A few sites suggest it might be a problem caused by a wrong version of the interpreter.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

勿忘初心 2024-09-15 23:38:55

你是对的,这是实现这一目标的方法之一。如果您的“String”变量不是字符串,它只会不起作用并抛出错误。

就我个人而言,我通常更喜欢使用类似的东西。

myString = string.lower(myString)

一样的

myString = myString:lower()

但是,它实际上与假设 myString 实际上是一个字符串是

。 “长”版本有一个优点,如果 myString 是数字,它实际上可以工作,而在这种情况下第二个版本会出错。

You're right, this is one of the ways to do it. It would only not work and throw errors if your "String" variable is not a string.

Personally, i usually prefer to use something like..

myString = string.lower(myString)

But its really the same as doing

myString = myString:lower()

assuming that myString is actually a string, however.

The "long" version has one advantage, it actually works if myString is a number, while the second one errors in that case.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文