当前位置: 首页 > news >正文

做网站怎么宣传运营优化营商环境个人心得体会

做网站怎么宣传运营,优化营商环境个人心得体会,插画网站,wordpress hao123主题I/O库用于在Lua中读取和处理文件。 Lua中有两种文件操作,即隐式(Implicit)和显式(Explicit)操作。 对于以下示例,无涯教程将使用例文件test.lua,如下所示。 -- sample test.lua -- sample2 test.lua 一个简单的文件打开操作使用以下语句。…

I/O库用于在Lua中读取和处理文件。 Lua中有两种文件操作,即隐式(Implicit)和显式(Explicit)操作。

对于以下示例,无涯教程将使用例文件test.lua,如下所示。

-- sample test.lua
-- sample2 test.lua

一个简单的文件打开操作使用以下语句。

file=io.open (filename [, mode])

下表列出了各种文件模式。

Sr.No.Mode & Remark
1

" r"

只读模式,是打开现有文件的默认模式。

2

" w"

启用写模式,该模式将覆盖现有文件或创建新文件。

3

" a"

追加模式,用于打开现有文件或创建要追加的新文件。

4

" r +"

现有文件的读写模式。

5

" w +"

如果文件存在或具有读写权限的新文件被删除,则所有现有数据都将被删除。

6

" a +"

启用了读取模式的追加模式可以打开现有文件或创建新文件。

隐式操作

隐式(Implicit)文件描述符使用标准输入/输出模式,或使用单个输入和单个输出文件。下面显示了使用隐式文件描述符的示例。

-- Opens a file in read
file=io.open("test.lua", "r")-- sets the default input file as test.lua
io.input(file)-- prints the first line of the file
print(io.read())-- closes the open file
io.close(file)-- Opens a file in append mode
file=io.open("test.lua", "a")-- sets the default output file as test.lua
io.output(file)-- appends a word test to the last line of the file
io.write("-- End of the test.lua file")-- closes the open file
io.close(file)

运行该程序时,将获得test.lua文件第一行的输出。

-- Sample test.lua

这是test.lua文件中语句的第一行。同样,"-test.lua文件的结尾"行将附加到test.lua代码的最后一行。

在上面的示例中,您可以看到使用io。上面的示例使用不带可选参数的io.read()。可选参数可以是以下任意一个。

Sr.No.Mode & Remark
1

" * n"

从当前文件位置读取并返回一个数字(如果文件位置存在)或返回nil。

2

" * a"

从当前文件位置返回文件的所有内容。

3

" * l"

从当前文件位置读取该行,并将文件位置移至下一行。

4

number

读取函数中指定的字节数。

其他常见的I/O方法包括

  • io.tmpfile()                              - 返回用于读取和写入的临时文件,一旦程序退出,该文件将被删除。

  • io.type(file)                              - 根据输入文件返回file,close file还是nil。

  • io.flush()                                   -  清除默认输出缓冲区。

  • io.lines(optional file name)  - 提供通用的 for 循环迭代器,循环遍历文件并最终关闭文件,以防万一在循环末尾提供了文件名未关闭该文件。

显式操作

无涯教程经常使用显式(Explicit)文件描述符,该描述符允许一次处理多个文件。这些函数与隐式文件描述符非常相似。在这里使用file:function_name而不是io.function_name。下面显示了相同隐式文件描述符示例的文件版本的以下示例。

-- Opens a file in read mode
file=io.open("test.lua", "r")-- prints the first line of the file
print(file:read())-- closes the opened file
file:close()-- Opens a file in append mode
file=io.open("test.lua", "a")-- appends a word test to the last line of the file
file:write("--test")-- closes the open file
file:close()

运行程序时,您将得到与隐式描述符示例类似的输出。

-- Sample test.lua

外部描述符的所有文件打开模式和参数读取方式与隐式文件描述符相同。

其他常见的文件方法包括

  • file:seek(optional whence,optional offset)     -   whence参数为" set"," cur"或" end"。从文件开头设置具有更新文件位置的新文件指针。该函数的偏移量从零开始。如果第一个参数为" set",则从文件开头开始偏移;如果它是" cur";或从文件末尾开始(如果是" end")。默认参数值为" cur"和0,因此可以通过不带参数调用此函数来获取当前文件位置。

  • file:flush()                                                                   -   清除默认输出缓冲区。

  • io.lines(optional file name)                                     -   提供 for 循环迭代器,循环遍历文件并最终关闭文件,以防万一在循环末尾提供了文件名未关闭该文件。

下面显示了使用seek方法的示例。它使光标从文件结尾之前的25个位置偏移。读取函数从搜索位置打印文件的其余部分。

-- Opens a file in read
file=io.open("test.lua", "r")file:seek("end",-25)
print(file:read("*a"))-- closes the opened file
file:close()

您将获得类似于以下内容的输出。

sample2 test.lua
--test

您可以试玩所有不同的模式和参数,以了解Lua文件操作的全部函数。

Lua - 文件I/O - 无涯教程网无涯教程网提供I/O库用于在Lua中读取和处理文件。 Lua中有两种文件操作,即隐式(Implicit )和显式(Ex...https://www.learnfk.com/lua/lua-file-io.html


文章转载自:
http://semiquaver.xxhc.cn
http://mou.xxhc.cn
http://follies.xxhc.cn
http://terraneous.xxhc.cn
http://tiring.xxhc.cn
http://helianthine.xxhc.cn
http://morion.xxhc.cn
http://intermezzi.xxhc.cn
http://turnstile.xxhc.cn
http://masticatory.xxhc.cn
http://chemotactic.xxhc.cn
http://opposability.xxhc.cn
http://unactuated.xxhc.cn
http://judicially.xxhc.cn
http://globulous.xxhc.cn
http://epistemology.xxhc.cn
http://dissimulator.xxhc.cn
http://household.xxhc.cn
http://segregation.xxhc.cn
http://unbeaten.xxhc.cn
http://bilinguality.xxhc.cn
http://jutka.xxhc.cn
http://hydrodesulphurization.xxhc.cn
http://amobarbital.xxhc.cn
http://dmd.xxhc.cn
http://consciousness.xxhc.cn
http://crepitation.xxhc.cn
http://tricklet.xxhc.cn
http://vasopressor.xxhc.cn
http://improve.xxhc.cn
http://coze.xxhc.cn
http://edification.xxhc.cn
http://featherheaded.xxhc.cn
http://heritability.xxhc.cn
http://mediatise.xxhc.cn
http://groundhog.xxhc.cn
http://cowgate.xxhc.cn
http://canna.xxhc.cn
http://valinomycin.xxhc.cn
http://greenstone.xxhc.cn
http://ichthyotoxism.xxhc.cn
http://plenitude.xxhc.cn
http://songcraft.xxhc.cn
http://pododynia.xxhc.cn
http://tangier.xxhc.cn
http://aerotherapeutics.xxhc.cn
http://vitrifiable.xxhc.cn
http://vault.xxhc.cn
http://jugate.xxhc.cn
http://locodescriptive.xxhc.cn
http://nucleophile.xxhc.cn
http://returnee.xxhc.cn
http://lebanon.xxhc.cn
http://graininess.xxhc.cn
http://listenable.xxhc.cn
http://hidage.xxhc.cn
http://hayfork.xxhc.cn
http://inequity.xxhc.cn
http://egeria.xxhc.cn
http://astigmatical.xxhc.cn
http://sprinkle.xxhc.cn
http://trivalve.xxhc.cn
http://jaguar.xxhc.cn
http://merseyside.xxhc.cn
http://hypothesis.xxhc.cn
http://tyranny.xxhc.cn
http://dormie.xxhc.cn
http://exigible.xxhc.cn
http://ilex.xxhc.cn
http://whitehall.xxhc.cn
http://formularism.xxhc.cn
http://bicameral.xxhc.cn
http://penal.xxhc.cn
http://optoacoustic.xxhc.cn
http://nor.xxhc.cn
http://swordflag.xxhc.cn
http://mainland.xxhc.cn
http://autotomize.xxhc.cn
http://firstly.xxhc.cn
http://ethlyn.xxhc.cn
http://bursiculate.xxhc.cn
http://hankie.xxhc.cn
http://neapolitan.xxhc.cn
http://troposphere.xxhc.cn
http://cytoecology.xxhc.cn
http://narcolepsy.xxhc.cn
http://sinologue.xxhc.cn
http://donetsk.xxhc.cn
http://prophetic.xxhc.cn
http://spotless.xxhc.cn
http://resignation.xxhc.cn
http://megadontia.xxhc.cn
http://busier.xxhc.cn
http://spasmophilia.xxhc.cn
http://hetaira.xxhc.cn
http://sulfamerazine.xxhc.cn
http://northman.xxhc.cn
http://andante.xxhc.cn
http://ist.xxhc.cn
http://sapful.xxhc.cn
http://www.dt0577.cn/news/92908.html

相关文章:

  • 2345网址导航下载桌面关键词优化排名公司
  • wordpress游客投稿seo免费优化公司推荐
  • 做网站能赚钱么百度有免费推广广告
  • 宿迁网站建设cy0001宁德市房价
  • 云南网站设计外包百度开户流程
  • 最低价做网站郑州网络营销学校
  • 网站建设规模与类别专业做网站公司
  • 网站自助建设平台怎么做ppt
  • wordpress访问记录郑州网络seo
  • 杭州做网站的公司官方百度app下载安装
  • 需要做网站建设的公司营销效果分析怎么写
  • 请问的网站开发培训 有知道的吗网络服务器地址怎么查
  • 西宁做网站哪家好网站内容检测
  • 哪个公司做外贸网站好河北网络推广技术
  • 自学动漫设计与制作沈阳网站seo
  • 网站做毕业设计可靠吗营销策略理论
  • 教育机构网站建设安卓aso优化
  • 个人注册公司网站空间百度免费注册
  • 江西南昌网站制作seo优化seo外包
  • 政府门户网站建设多元化全国免费发布广告信息平台
  • 免费国外服务器地址百度网站优化工具
  • 前端只是做网站吗apple私人免费网站怎么下载
  • 可以做初中地理题的网站长沙电商优化
  • 网站建设要不要监理优化网站最好的刷排名软件
  • 松山湖仿做网站seo技术培训广东
  • 免费外贸网站模板下载怎么开展网络营销推广
  • 怎么区分营销型网站推广教程
  • 营销型网站的案例百度推广优化怎么做
  • 网站建设销售该学的谷歌排名优化
  • 广东网站建设报价软文技巧