如何在字符串中添加 chr(47) '\'?

local html_path = "[[" .. GetPostProcessorLocation()
html_path = html_path .. ????  .. "New Please Register Me.html]]"

chr(47)
"\"
请告诉我需要输入什么以继续?

点赞
用户1244588
用户1244588

字符 47 是正斜杠(/), 而不是反斜杠(\)。反斜杠是字符 92。我猜您想说的应该是反斜杠,因为正斜杠通常不会引起问题。

我也不确定您想使用方括号([[..]])达到什么目的,因为这实际上是Lua中表示没有其他处理的多行字符串的方法。以下是来自Lua 5.2 REPL的示例输出,希望对您有所帮助:

Lua 5.2.4  版权所有(C) 1994-2015 Lua.org, PUC-Rio
> function GetPostProcessorLocation() return "C:\\Programs"; end
>
> print("[[" .. GetPostProcessorLocation() .. string.char(92)  .. "New Please Register Me.html]]")
[[C:\Programs\New Please Register Me.html]]
> print(GetPostProcessorLocation() .. string.char(92)  .. [[New Please Register Me.html]])
C:\Programs\New Please Register Me.html
> print(GetPostProcessorLocation() .. [[\New Please Register Me.html]])
C:\Programs\New Please Register Me.html
> print(GetPostProcessorLocation() .. [[\\New Please Register Me.html]])
C:\Programs\\New Please Register Me.html
> -- 请注意上面输出中的双反斜杠!
> print(GetPostProcessorLocation() .. "\\New Please Register Me.html")
C:\Programs\New Please Register Me.html
> print(string.format("%s\\%s", GetPostProcessorLocation(), "New Please Register Me.html"))
C:\Programs\New Please Register Me.html
2019-06-12 10:58:42