模块 os
require "os"
公开 API
| API | 实现 | 说明 |
|---|---|---|
os.clock | os_clock | 返回程序运行的 CPU 时间(秒) |
os.date | os_date | 格式化日期:format 含 '!' 为 UTC,'*t' 返回表 |
os.difftime | os_difftime | 返回 t2-t1 的时间差(秒) |
os.execute | os_execute | 执行系统命令;无参返回环境检测,有参返回 exit 码/信号/布尔 |
os.exit | os_exit | 终止进程,可选退出码(默认 0 或 EXIT_SUCCESS) |
os.getenv | os_getenv | 读取环境变量,不存在返回 nil |
os.remove | os_remove | 删除文件,成功返回 true,失败返回 nil+错误 |
os.rename | os_rename | 重命名文件/目录,成功返回 true,失败返回 nil+错误 |
os.setlocale | os_setlocale | 设置/查询区域设置 |
os.time | os_time | 返回当前时间(时间戳)或由表参数构造的时间 |
os.tmpname | os_tmpname | 生成唯一临时文件名(不创建文件) |