node之path模块

path模块
  传入一个路径,处理该路径

  

const path=require("path");
let pathUrl="D:/workspace/airtest/suite/1.txt";
console.log(path.dirname(pathUrl));//获取目录 D:/workspace/airtest
console.log(path.extname(pathUrl));//获取文件后缀 txt
console.log(path.basename(pathUrl));//获取文件 1.txt

console.log(path.resolve(pathUrl,"../uuu"));//路径拼接 D:\workspace\airtest\suite\uuu
console.log(path.resolve(__dirname,"www"));//当前源文件所在目录 d:\workspace\node\day4\www

 

  

posted on 2019-02-21 16:49  悬剑  阅读(77)  评论(0编辑  收藏  举报

导航