I have some text and I'm trying to load it via load string. The following works:local m = loadstring("data = 5")()But when the data is a table it doesn't work and gives the error "attempt to call a nil"local m = loadstring("data = { 1 = 10}")() 解决方案 The table declaration in lua require integer keys to be put inside square brackets:data = { [1] = value,}The enclosing of keys in square brackets is always allowed, valid and possible. It can be skipped iff your key follows the pattern: [A-Za-z_][A-Za-z0-9_]* (which is the same as a valid variable name in lua) 这篇关于lua的loadstring()不适用于表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-26 05:46
查看更多