node06-path
目录:
node01-创建服务器
node02-util
node03-events
node04-buffer
node05-fs
node06-path
node07-http
node08-express
node09-cookie
path模块:
1 var path = require("path"); 2 //规范化路径 3 var str = "a/b/c/../d/./../f/e/"; 4 var pathstr = path.normalize(str); 5 console.log(pathstr); 6 7 //将多个字符串路径组合成一个路径 8 console.log(path.join(__filename,"a/b","c/d","../e")); 9 10 //resolve 解析成绝对路径 11 console.log(path.resolve("www","baidu","com")); 12 console.log(path.resolve("/www","fgg"));