node.js 中内置模块 path模块的基本使用
//node加载文件是同步执行的 执行代码会被阻塞
//加载过后的模块会被缓存 ,加载过后的模块module里面的loaded会变为true
//node 使用的加载方式是深度优先
// 一
// const path = require('path')
// const basePath = '/user/stu';
// const filename = 'hu.text'
// const p = path.resolve(basePath,filename)
// console.log(p);
// 二
// const path = require('path')
// const basepath ='./user/stu'
// const filename = 'hu.text'
// const name = path.resolve(basepath,filename)
// const name2 = path.join(basepath,filename)
// path.resolve 不只是会对路径/的转化,还会对..或者.进行转化
// path.join 只会对路径中的/进行转化
// console.log(name);
// console.log(name2);
// 三
// const path = require('path')
// const basepath ='./user/stu'
// const filename = 'hu.text'
// const name = path.resolve(basepath,filename)
// console.log(path.dirname(name));//获取路径文件夹
// console.log(path.extname(name));//获取路径的扩展名
// console.log(path.basename(name));//获取文件的名字包括扩展名