Lua丨文件I/O

版权声明:欢迎转载,转载请注明出处 https://blog.csdn.net/weixin_38239050/article/details/82561766
file=io.open("test.txt","r")
io.input(file)
--read方法:若括号内无内容,则输出第一行,重复read,继续输出下一行
        --若含有数字,则是输出多少字符。重复read,则继续输出,不会从头开始
        --当输出到末尾时,返回nil
print(io.read(2))
print(io.read(3))
io.close(file)




>lua -e "io.stdout:setvbuf 'no'" "lua.lua" 
sk
ode
>Exit code: 0

猜你喜欢

转载自blog.csdn.net/weixin_38239050/article/details/82561766
今日推荐