这串字符串是什么意思,能否详细解释一番?
- 内容介绍
- 文章标签
- 相关推荐
本文共计172个文字,预计阅读时间需要1分钟。
我使用LuaSocket和http.request调用生成Lua表,并将其输出到浏览器的远程+PHP脚本。当http.request响应存储在变量中时,它是一个字符串,这使得该表在我的Lua代码中不可用。例如:eventData。
我使用LuaSocket和www.example.com/events.php") print( eventData ) --print outputs this "string", that is really a Lua table that PHP generated months={ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December', }例如,如果我尝试拨打几个月[4],它会错误地“尝试索引全球’月'(零值)”.
如何将该字符串转换为可用的表?
谢谢!
您可以使用 loadstring创建可以执行的lua块.eventData = [[ months = { 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December', } ]] loadstring(eventData)() if months then print(table.concat(months, ", ")) end
本文共计172个文字,预计阅读时间需要1分钟。
我使用LuaSocket和http.request调用生成Lua表,并将其输出到浏览器的远程+PHP脚本。当http.request响应存储在变量中时,它是一个字符串,这使得该表在我的Lua代码中不可用。例如:eventData。
我使用LuaSocket和www.example.com/events.php") print( eventData ) --print outputs this "string", that is really a Lua table that PHP generated months={ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December', }例如,如果我尝试拨打几个月[4],它会错误地“尝试索引全球’月'(零值)”.
如何将该字符串转换为可用的表?
谢谢!
您可以使用 loadstring创建可以执行的lua块.eventData = [[ months = { 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December', } ]] loadstring(eventData)() if months then print(table.concat(months, ", ")) end

