将数据覆盖写入到文件 (file.writes)

声明

写入成败 = file.writes(文件路径, 待写入内容)

参数及返回值

  • 文件路径
    • 文本型,文件绝对路径
  • 待写入内容
    • 字符串型,需要写入的数据
  • 写入成败
    • 布尔型,操作成功返回 true,操作失败返回 false

说明

将数据覆盖写入到文件,文件不存在会创建文件,目录不存在会自动创建目录
file模块操作的文件位于ATP服务器,如果你要操作手机设备的文件,请使用pfile模块。

示例

local success = file.writes("/var/mobile/1.txt", "苟")
if success then
    print("写入成功")
else
    print("写入失败")
end
powered by GitbookFile Modify: 2021-03-27 23:14:19

results matching ""

    No results matching ""