为Lua的string.format转义字符串

use*_*846 6 string lua escaping lua-patterns

我有一个字符串,我需要添加一个变量,所以我使用该string.format方法,但字符串也包含符号"%20"(不知道它代表什么,可能是一个空格或其他东西).无论如何,因为字符串包含多个"%",我只想将变量添加到第一个设置id,有没有办法在点或其他东西转义字符串?

就像现在一样:

ID = 12345
string.format("id=%s&x=foo=&bar=asd%20yolo%20123-1512", ID)
Run Code Online (Sandbox Code Playgroud)

我得到bad argument #3 to 'format' (no value).错误 - 因为它期望传递3个变量.

dun*_*123 5

你可以逃避%另一个%,例如string.format("%%20")将给予%20