佚名通过本文主要向大家介绍了stringformat,c stringformat,wpf stringformat,stringformatflags,simplestringformat等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题:Lua 关于可变参数和stringformat的问题
描述:
解决方案1:
描述:
function fwrite(fmt,...)
return io.write(string.format(fmt,unpack(arg)))
end
print(fwrite(1,string.find("dubowen","bowe")))
结果是1true
这个结果在我预料之外,不知道为什么会是这个。
主要string.format我理解的也不好。
解决方案1:
你什么版本的lua
?
我5.2.3
版本打印1file (0x7f592ee78280)
(括号中的数据每次运行都不同).
首先string.format(fmt,unpack(arg))
返回1
(这个你应该知道为什么吧?)
io.write
把1
输出到屏幕(所以打印结果中有个1
),
然后io.write
返回output file descriptor
, print
打印这个output file descriptor
就是类似于file (0x7f592ee78280)
这样的值.
所以最终看到的打印1file (0x7f592ee78280)
其实分别是有io.wirte
打印的1
和print
打印的file (0x7f592ee78280)
组合结果.