This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
playground:playground:zh [2023/11/29 05:07] hfsr |
playground:playground:zh [2023/11/29 05:21] (current) hfsr |
||
---|---|---|---|
Line 8: | Line 8: | ||
示例:`local chars = b:read(10)` | 示例:`local chars = b:read(10)` | ||
\\ | \\ | ||
- | * "\*n" 或 "\*number" | + | * `*n`或者`*number` |
从IO流中读取下一组可被解释为数字的字节。请注意读取到的数字会受到打开模式为二进制还是文本的影响。参见[[api:non-standard-lua-libs#input_and_output_facilities|io.open]]以获取有关如何以不同模式打开文件的更多信息。 | 从IO流中读取下一组可被解释为数字的字节。请注意读取到的数字会受到打开模式为二进制还是文本的影响。参见[[api:non-standard-lua-libs#input_and_output_facilities|io.open]]以获取有关如何以不同模式打开文件的更多信息。 | ||
示例:`local number = b:read("*n")` | 示例:`local number = b:read("*n")` | ||
\\ | \\ | ||
- | * "\*l"或者"\*line" | + | * `*l`或者`*line` |
从IO流中读取下一行,截掉换行标记(可能是 \n,、\r或\r\n)。 | 从IO流中读取下一行,截掉换行标记(可能是 \n,、\r或\r\n)。 | ||
示例:`local line = b:read("*l")` | 示例:`local line = b:read("*l")` | ||
\\ | \\ | ||
- | * "\*L"或者"\*Line" | + | * `*L`或者`*Line` |
- | 从IO流中读取下一行,类似"*line",但是在结果中保留换行标记。 | + | 从IO流中读取下一行,类似`*line`,但是在结果中保留换行标记。 |
示例:`local whole_line = b:read("*L")` | 示例:`local whole_line = b:read("*L")` | ||
\\ | \\ | ||
- | * "\*a"或者"\*all" | + | * `*a`或者`*all` |
从IO流中读取所有剩余内容,直到遇到nil。在此读取格式后再指定其他格式没有意义。 | 从IO流中读取所有剩余内容,直到遇到nil。在此读取格式后再指定其他格式没有意义。 | ||
- | 示例:`local the_whole_file = b:read("*a")` | + | 示例:`local the_whole_file = b:read("*a")`\\ |
- | \\ | + | \\ |
- | * "\*L"或者"\*Line" | + | |
- | 从IO流中读取下一行,类似"*line",但是在结果中保留换行标记。 | + | |
- | 示例:`local whole_line = b:read("*L")` | + | |
- | \\ | + | |
- `b:getTimeout() number` | - `b:getTimeout() number` | ||
返回当前带缓冲流设定的超时时间(单位为秒)。默认超时时间为`math.huge`。参阅`setTimeout`以获取有关于带缓冲流超时时间影响的更多信息。 | 返回当前带缓冲流设定的超时时间(单位为秒)。默认超时时间为`math.huge`。参阅`setTimeout`以获取有关于带缓冲流超时时间影响的更多信息。 | ||
\\ | \\ |