Lua string to int

后端 未结 12 1343
礼貌的吻别
礼貌的吻别 2020-12-23 08:39

How can I convert a string to an integer in Lua?

I have a string like this:

a = \"10\"

I would like it to be converted to 10, the n

12条回答
  •  猫巷女王i
    2020-12-23 09:06

    Lua 5.3.1  Copyright (C) 1994-2015 Lua.org, PUC-Rio
    > math.floor("10");
    10
    > tonumber("10");
    10
    > "10" + 0;
    10.0
    > "10" | 0;
    10
    

提交回复
热议问题