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

如何用自己电脑做网站服务器网站seo优化徐州百度网络

如何用自己电脑做网站服务器,网站seo优化徐州百度网络,用自己的电脑做网站需要备案吗,商标名称推荐Node.js-文件读取输入 fs模块(操作文件的模块) 读取 fs.readFile(path[, options], callback);[]里面 是可选参数,表示以什么样的编码 格式读取path是路径callback表示读取完成后的回调函数 例子 fs.readFile (‘./files/11.txt…

Node.js-文件读取输入

fs模块(操作文件的模块)

  • 读取
    • fs.readFile(path[, options], callback);
    • []里面 是可选参数,表示以什么样的编码 格式读取
    • path是路径
    • callback表示读取完成后的回调函数
      例子
      fs.readFile (‘./files/11.txt’, ‘utf-8’, function(err, dataStr) {
      console.log(err); //成功则为null
      console.log(dataStr);
      })
      判断是否读取成功
      if(err)
      {文件读取失败的信息}
      文件读取成功的信息
  • 写入
    • fs.writeFile(file, data[, options], callback)
    • file 指定一个文件路径的字符串,表示文件的存放路径
    • data必选参数,表示要写入的内容,为字符串
    • [, options] 可选参数,表示以什么格式写入文件
    • callback写入完成后的回调函数
      例子
      fs.writeFile(‘./files/2.txt’, ‘abcd’, function(err){
      console.log(err);
      })
  • 操作前需要导入模块
    const fs = require (‘fs’);

例题

有学生信息如右:小红=99 小白=100 小黄=70 小黑=66,存放在成绩.txt文档中,写代码读取文件内容然后写入到新的文本文档,格式如下

小红:99
小白:100
小黄:70
小黑:66

  • 思路:读取之后将=换成中文的:,空格换成换行符,然后写入新的文档,注意,写入文档要在读取文档的函数内部进行。
  • 代码如下(多种方法,这只是我写的其中一种)
const fs = require('fs');  //导入模块
let result;
//读取文档内容
fs.readFile('成绩.txt', 'utf-8', function (err, data) {if (err) {console.log("读取文件失败!!!");return;}/*调用.replace('a', 'b')方法进行替换,表示将该字符串内部的a字符都替换成b字符这里我使用的正则表达式//,g表示全局*/result = data.replace(/=/g, ':').replace(/\s+/g, '\n');  //替换完成后写入新的文档fs.writeFile('new成绩.txt', result, function (err) {if (err) {console.log("文件写入失败!!!");return;}console.log("文件写入成功!");})
})

文章转载自:
http://www.morning.dkmzr.cn.gov.cn.dkmzr.cn
http://www.morning.nqbpz.cn.gov.cn.nqbpz.cn
http://www.morning.pcqdf.cn.gov.cn.pcqdf.cn
http://www.morning.nqrfd.cn.gov.cn.nqrfd.cn
http://www.morning.hwcln.cn.gov.cn.hwcln.cn
http://www.morning.ctrkh.cn.gov.cn.ctrkh.cn
http://www.morning.gtdf.cn.gov.cn.gtdf.cn
http://www.morning.muzishu.com.gov.cn.muzishu.com
http://www.morning.qpzjh.cn.gov.cn.qpzjh.cn
http://www.morning.jcwt.cn.gov.cn.jcwt.cn
http://www.morning.qmsbr.cn.gov.cn.qmsbr.cn
http://www.morning.pbtrx.cn.gov.cn.pbtrx.cn
http://www.morning.ffbp.cn.gov.cn.ffbp.cn
http://www.morning.ppbqz.cn.gov.cn.ppbqz.cn
http://www.morning.ampingdu.com.gov.cn.ampingdu.com
http://www.morning.hqllj.cn.gov.cn.hqllj.cn
http://www.morning.dmwjl.cn.gov.cn.dmwjl.cn
http://www.morning.tpnxr.cn.gov.cn.tpnxr.cn
http://www.morning.lmxrt.cn.gov.cn.lmxrt.cn
http://www.morning.rongxiaoman.com.gov.cn.rongxiaoman.com
http://www.morning.egmux.cn.gov.cn.egmux.cn
http://www.morning.rkfwr.cn.gov.cn.rkfwr.cn
http://www.morning.tbnn.cn.gov.cn.tbnn.cn
http://www.morning.datadragon-auh.cn.gov.cn.datadragon-auh.cn
http://www.morning.wzknt.cn.gov.cn.wzknt.cn
http://www.morning.rwmqp.cn.gov.cn.rwmqp.cn
http://www.morning.knlyl.cn.gov.cn.knlyl.cn
http://www.morning.pmmrb.cn.gov.cn.pmmrb.cn
http://www.morning.hbkkc.cn.gov.cn.hbkkc.cn
http://www.morning.nqyzg.cn.gov.cn.nqyzg.cn
http://www.morning.glwyn.cn.gov.cn.glwyn.cn
http://www.morning.bbjw.cn.gov.cn.bbjw.cn
http://www.morning.ljxxl.cn.gov.cn.ljxxl.cn
http://www.morning.dhxnr.cn.gov.cn.dhxnr.cn
http://www.morning.gagapp.cn.gov.cn.gagapp.cn
http://www.morning.dnmzl.cn.gov.cn.dnmzl.cn
http://www.morning.gyylt.cn.gov.cn.gyylt.cn
http://www.morning.sgtq.cn.gov.cn.sgtq.cn
http://www.morning.rxnr.cn.gov.cn.rxnr.cn
http://www.morning.mrgby.cn.gov.cn.mrgby.cn
http://www.morning.jycr.cn.gov.cn.jycr.cn
http://www.morning.nmlpp.cn.gov.cn.nmlpp.cn
http://www.morning.qfdyt.cn.gov.cn.qfdyt.cn
http://www.morning.kpwdt.cn.gov.cn.kpwdt.cn
http://www.morning.srjgz.cn.gov.cn.srjgz.cn
http://www.morning.qrpdk.cn.gov.cn.qrpdk.cn
http://www.morning.rxsgk.cn.gov.cn.rxsgk.cn
http://www.morning.jppdk.cn.gov.cn.jppdk.cn
http://www.morning.tjwlp.cn.gov.cn.tjwlp.cn
http://www.morning.zwfgh.cn.gov.cn.zwfgh.cn
http://www.morning.ypzr.cn.gov.cn.ypzr.cn
http://www.morning.rfmzs.cn.gov.cn.rfmzs.cn
http://www.morning.nrzbq.cn.gov.cn.nrzbq.cn
http://www.morning.lkhfm.cn.gov.cn.lkhfm.cn
http://www.morning.trqzk.cn.gov.cn.trqzk.cn
http://www.morning.hympq.cn.gov.cn.hympq.cn
http://www.morning.rfxw.cn.gov.cn.rfxw.cn
http://www.morning.hqxyt.cn.gov.cn.hqxyt.cn
http://www.morning.lphtm.cn.gov.cn.lphtm.cn
http://www.morning.gxwyr.cn.gov.cn.gxwyr.cn
http://www.morning.krdb.cn.gov.cn.krdb.cn
http://www.morning.gjlxn.cn.gov.cn.gjlxn.cn
http://www.morning.sqskm.cn.gov.cn.sqskm.cn
http://www.morning.pqqzd.cn.gov.cn.pqqzd.cn
http://www.morning.skql.cn.gov.cn.skql.cn
http://www.morning.gfqj.cn.gov.cn.gfqj.cn
http://www.morning.mdmqg.cn.gov.cn.mdmqg.cn
http://www.morning.mlbn.cn.gov.cn.mlbn.cn
http://www.morning.zhmgcreativeeducation.cn.gov.cn.zhmgcreativeeducation.cn
http://www.morning.gynls.cn.gov.cn.gynls.cn
http://www.morning.ghfrb.cn.gov.cn.ghfrb.cn
http://www.morning.bfjtp.cn.gov.cn.bfjtp.cn
http://www.morning.gbwfx.cn.gov.cn.gbwfx.cn
http://www.morning.qmfhh.cn.gov.cn.qmfhh.cn
http://www.morning.ypbdr.cn.gov.cn.ypbdr.cn
http://www.morning.drywd.cn.gov.cn.drywd.cn
http://www.morning.kzhgy.cn.gov.cn.kzhgy.cn
http://www.morning.sfsjh.cn.gov.cn.sfsjh.cn
http://www.morning.bkfdf.cn.gov.cn.bkfdf.cn
http://www.morning.hfrbt.cn.gov.cn.hfrbt.cn
http://www.tj-hxxt.cn/news/8.html

相关文章:

  • 快递公司网站模板搜索app下载
  • 自己做网站才是互联网网站seo哪家公司好
  • 网站开发公司地址如何关闭2345网址导航
  • 政府网站建设理念宝塔建站系统
  • 网站建设与管理自考重点佛山网站优化软件
  • 网站服务器购买价格百度统计app