且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何为Lua表添加前缀?

更新时间:2023-12-01 10:36:10

您可以使用环境loadfile("mydata","t",XYZ)XYZ加载文件.参见手册中的 loadfile .

You can load the file with XYZ as is environment: loadfile("mydata","t",XYZ). See loadfile in the manual.

这在Lua 5.2中有效.对于Lua 5.1,请使用loadfile,然后使用setfenv.

This works in Lua 5.2. For Lua 5.1, use loadfile followed by setfenv.