Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试捕获例如的输出: print('Hello') 并将其存储在变量/表中。
请让我知道这是否可能。如果不是感谢您的回答。
不能直接截取标准输出,但是可以改变全局print函数:
print
local outputs = {} local function storeOutputs(...) table.insert(outputs, {...}) end local oldPrint = print function print(...) storeOutputs(...) oldPrint(...) end
我不确定是否有办法处理io.write电话。
io.write