广州葆元健康生物科技有限公司


node.js中的path.extname方法使用说明

网络编程 node.js中的path.extname方法使用说明 06-21

方法说明:

返回path路径文件扩展名,如果path以 ‘.' 为结尾,将返回 ‘.',如果无扩展名 又 不以'.'结尾,将返回空值。

语法:

path.extname(p)

由于该方法属于path模块,使用前需要引入path模块(var path= require(“path”) )

接收参数:

p path路径

例子:

path.extname('index.html')

// returns

'.html'

path.extname('index.')

// returns

'.'

path.extname('index')

// returns

''

源码:

exports.extname = function(path) { 

  return splitPath(path)[3]; 

};

node.js中的path.dirname方法使用说明
方法说明:返回path的目录。类似于UNIX目录命令。语法:path.dirname(p)由于该方法属于path模块,使用前需要引入path模块(varpath=require(path))接收参数:ppat

node.js中的path.delimiter方法使用说明
方法说明:方法将返回平台的真实路径,多个用:或;隔开。语法:path.delimiter由于该方法属于path模块,使用前需要引入path模块(varpath=require(path))接收

node.js中的path.basename方法使用说明
方法说明:提取出用‘/'隔开的path的最后一部分。(8详见例子)语法:path.basename(p,[ext])由于该方法属于path模块,使用前需要引入path模块(varpath=require(


编辑:广州葆元健康生物科技有限公司

标签:方法,模块,语法,使用说明,路径