lua io操作


lua io操作

       

           

                                 

io 操作

        

相关函数

io.close(file):关闭文件,file可选,如果没有指定,关闭默认的文件
io.flush():刷新文件

io.input ([file]):设置默认输入文件,io.read从文件中读取内容
io.output ([file]):设置默认的输出文件,io.write向文件中写入内容

io.write (···):向默认文件中写入内容,...为字符串(写入文件的内容)

io.lines ([filename, ···]):以可读模式打开文件,每次返回一行数据
                            当到文件尾时,将返回nil,但不关闭文件
                            如不指定filename,则从控制态读取数据

       

io.read(format):读取文件内容的格式

Reads the file file, according to the given formats, which specify what to read. 
For each format, the function returns a string or a number with the characters 
read, or fail if it cannot read data with the specified format. (In this latter 
case, the function does not read subsequent formats.) When called without 
arguments, it uses a default format that reads the next line (see below).
* 根据指定的格式读取文件内容

The available formats are
    "n": reads a numeral and returns it as a float or an integer, following the 
lexical conventions of Lua. (The numeral may have leading whitespaces and a sign.) 
This format always reads the longest input sequence that is a valid prefix for a 
numeral; if that prefix does not form a valid numeral (e.g., an empty string, "0x", 
or "3.4e-"
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值