国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

Lua讀寫文件代碼示例

2024-07-21 23:04:34
字體:
來源:轉載
供稿:網(wǎng)友

讀寫文件的模式:

復制代碼 代碼如下:

r - 讀取模式w - 寫入模式(覆蓋現(xiàn)有內容) 
a - 附加模式(附加在現(xiàn)有內容之后) 
b - 二進制模式 
r+ - 讀取更新模式(現(xiàn)有數(shù)據(jù)保留) 
w+ - 寫入更新模式(現(xiàn)有數(shù)據(jù)擦除) 
a+ - 附加更新模式(現(xiàn)有數(shù)據(jù)保留,只在文件末尾附加) 

 

 

do   --read data from file    function readFile()     local fileHandle = assert(io.open("test.txt", "r"), "not the file");     if fileHandle then       local outData = fileHandle:read("*all");       print(outData);     else       print("false");     end       fileHandle:close(errorInfo);   end    --write data to the file   function writeFile(dataBuffer)     local writeHandle = assert(io.open("write.txt", "a+"), "not the file");      if writeHandle then       writeHandle:write(dataBuffer);       print("true");     else       print("false");     end      writeHandle:close();   end     local inputData = 0;    repeat     inputData = io.read(); --write the data from io     writeFile(inputData);   until inputData == '#'   end

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 通河县| 临沂市| 蓬莱市| 肇庆市| 徐闻县| 克东县| 阳西县| 南丰县| 额尔古纳市| 团风县| 积石山| 海伦市| 凌云县| 钟祥市| 濮阳县| 电白县| 盘山县| 库尔勒市| 尼木县| 白河县| 兴仁县| 同仁县| 壤塘县| 政和县| 隆德县| 定南县| 弥勒县| 景德镇市| 牙克石市| 罗平县| 津南区| 依兰县| 米泉市| 麦盖提县| 共和县| 通州市| 枞阳县| 长宁县| 杨浦区| 霍林郭勒市| 西城区|