国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 上饶市| 宁海县| 平阳县| 东光县| 芒康县| 正安县| 仪陇县| 万载县| 马山县| 郧西县| 康保县| 吴江市| 西和县| 轮台县| 保定市| 搜索| 长治市| 榆中县| 平南县| 泗阳县| 石家庄市| 长岭县| 南岸区| 临海市| 崇阳县| 内丘县| 明水县| 东平县| 洪雅县| 岐山县| 丹凤县| 城口县| 尉氏县| 临清市| 驻马店市| 南宁市| 巴青县| 九台市| 前郭尔| 呼玛县| 开鲁县|